Advertisement
JP_Bispo123

Pesquisa

Sep 12th, 2018
2,498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.78 KB | None | 0 0
  1. using Database;
  2. using Model;
  3. using MongoDB.Bson;
  4. using MongoDB.Driver;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14.  
  15. namespace View
  16. {
  17. public partial class Pesquisa : Form
  18. {
  19. string Buscar = "";
  20. public Pesquisa()
  21. {
  22. InitializeComponent();
  23. }
  24.  
  25.  
  26. private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  27. {
  28. dataGridView1.ReadOnly = true;
  29. }
  30.  
  31. private void button2_Click_1(object sender, EventArgs e)
  32. {
  33. MenuEstoque menu = new MenuEstoque();
  34. menu.Show();
  35. this.Visible = false;
  36. }
  37.  
  38. private void button1_Click(object sender, EventArgs e)
  39. {
  40.  
  41. Estoque aux = new Estoque();
  42.  
  43. if (textBox1.Text.Length > 0)
  44. {
  45. aux = MongoConnection.QueryCollection("Estoques", Builders<Estoque>.Filter.Where(c => c.codHVEX.Equals(Buscar)), null).First();
  46. }
  47. if(textBox2.Text.Length > 0)
  48. {
  49. aux = MongoConnection.QueryCollection("Estoques", Builders<Estoque>.Filter.Where(c => c.produto.Contains(Buscar)), null).First();
  50. }
  51. if(textBox3.Text.Length > 0)
  52. {
  53. aux = MongoConnection.QueryCollection("Estoques", Builders<Estoque>.Filter.Where(c => c.descricao.Contains(Buscar)), null).First();
  54. }
  55.  
  56. for (int i = 0; i < 1; i++)
  57. {
  58. DataGridViewRow item = new DataGridViewRow();
  59.  
  60. item.CreateCells(dataGridView1);
  61. dataGridView1.Rows.Add(item);
  62.  
  63. dataGridView1.Rows[i].Cells[0].Value = aux.tipo; // Seta os valores da célula
  64. dataGridView1.Rows[i].Cells[0].ReadOnly = true; //Trava a célula para o usuário não poder modificá-la
  65.  
  66. dataGridView1.Rows[i].Cells[1].Value = aux.produto;
  67. dataGridView1.Rows[i].Cells[1].ReadOnly = true;
  68.  
  69. dataGridView1.Rows[i].Cells[2].Value = aux.descricao;
  70. dataGridView1.Rows[i].Cells[2].ReadOnly = true;
  71.  
  72. dataGridView1.Rows[i].Cells[3].Value = aux.setor;
  73. dataGridView1.Rows[i].Cells[3].ReadOnly = true;
  74.  
  75. dataGridView1.Rows[i].Cells[4].Value = aux.fabricante;
  76. dataGridView1.Rows[i].Cells[4].ReadOnly = true;
  77.  
  78. dataGridView1.Rows[i].Cells[5].Value = aux.fornecedor;
  79. dataGridView1.Rows[i].Cells[5].ReadOnly = true;
  80.  
  81. dataGridView1.Rows[i].Cells[6].Value = aux.quantidade;
  82. dataGridView1.Rows[i].Cells[6].ReadOnly = true;
  83.  
  84. dataGridView1.Rows[i].Cells[7].Value = aux.Preco;
  85. dataGridView1.Rows[i].Cells[7].ReadOnly = true;
  86.  
  87. dataGridView1.Rows[i].Cells[8].Value = aux.partNumb;
  88. dataGridView1.Rows[i].Cells[8].ReadOnly = true;
  89.  
  90. dataGridView1.Rows[i].Cells[9].Value = aux.codHVEX;
  91. dataGridView1.Rows[i].Cells[9].ReadOnly = true;
  92. }
  93. }
  94. private void textBox1_TextChanged_1(object sender, EventArgs e)
  95. {
  96. if (textBox1.Text.Length == 0)
  97. {
  98. textBox2.Enabled = true;
  99. textBox3.Enabled = true;
  100. Buscar += textBox1.Text;
  101. }
  102. else
  103. {
  104. textBox2.Enabled = false;
  105. textBox3.Enabled = false;
  106. }
  107. dataGridView1.ReadOnly = true;
  108. }
  109.  
  110. private void textBox2_TextChanged_1(object sender, EventArgs e)
  111. {
  112. if (textBox2.Text.Length == 0)
  113. {
  114. textBox1.Enabled = true;
  115. textBox3.Enabled = true;
  116. Buscar += textBox2.Text;
  117. }
  118. else
  119. {
  120. textBox1.Enabled = false;
  121. textBox3.Enabled = false;
  122. }
  123. dataGridView1.ReadOnly = true;
  124. }
  125.  
  126. private void textBox3_TextChanged_1(object sender, EventArgs e)
  127. {
  128. if (textBox3.Text.Length == 0)
  129. {
  130. textBox1.Enabled = true;
  131. textBox2.Enabled = true;
  132. Buscar += textBox3.Text;
  133. }
  134. else
  135. {
  136. textBox1.Enabled = false;
  137. textBox2.Enabled = false;
  138. }
  139. dataGridView1.ReadOnly = true;
  140. }
  141.  
  142. private void groupBox1_Enter(object sender, EventArgs e)
  143. {
  144.  
  145. }
  146. }
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement