Advertisement
JP_Bispo123

Pesquisa

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