Advertisement
JP_Bispo123

Untitled

Aug 29th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 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. private void button1_Click_1(object sender, EventArgs e)
  25. {
  26. var aux = MongoConnection.QueryCollection("Produto", Builders<Estoque>.Filter.Where(c => c.codAlf.Contains(Buscar)), null).First();
  27.  
  28. for(int i = 0; i < 1; i++)
  29. {
  30. DataGridViewRow item = new DataGridViewRow();
  31.  
  32. item.CreateCells(dataGridView1);
  33. dataGridView1.Rows.Add(item);
  34.  
  35. dataGridView1.Rows[i].Cells[0].Value = aux.tipo; // Seta os valores da célula
  36. dataGridView1.Rows[i].Cells[0].ReadOnly = true; //Trava a célula para o usuário não poder modificá-la
  37.  
  38. dataGridView1.Rows[i].Cells[1].Value = aux.produto;
  39. dataGridView1.Rows[i].Cells[1].ReadOnly = true;
  40.  
  41. dataGridView1.Rows[i].Cells[2].Value = aux.descricao;
  42. dataGridView1.Rows[i].Cells[2].ReadOnly = true;
  43.  
  44. dataGridView1.Rows[i].Cells[3].Value = aux.setor;
  45. dataGridView1.Rows[i].Cells[3].ReadOnly = true;
  46.  
  47. dataGridView1.Rows[i].Cells[4].Value = aux.fabricante;
  48. dataGridView1.Rows[i].Cells[4].ReadOnly = true;
  49.  
  50. dataGridView1.Rows[i].Cells[5].Value = aux.fornecedor;
  51. dataGridView1.Rows[i].Cells[5].ReadOnly = true;
  52.  
  53. dataGridView1.Rows[i].Cells[6].Value = aux.quantidade;
  54. dataGridView1.Rows[i].Cells[6].ReadOnly = true;
  55.  
  56. dataGridView1.Rows[i].Cells[7].Value = aux.Preco;
  57. dataGridView1.Rows[i].Cells[7].ReadOnly = true;
  58.  
  59. dataGridView1.Rows[i].Cells[8].Value = aux.partNumb;
  60. dataGridView1.Rows[i].Cells[8].ReadOnly = true;
  61.  
  62. dataGridView1.Rows[i].Cells[9].Value = aux.codAlf;
  63. dataGridView1.Rows[i].Cells[9].ReadOnly = true;
  64.  
  65. dataGridView1.Rows[dataGridView1.NewRowIndex].Cells[0].Selected = true;
  66. }
  67. }
  68.  
  69. private void textBox1_TextChanged(object sender, EventArgs e)
  70. {
  71. if (textBox1.Text.Length == 0)
  72. {
  73. textBox2.Enabled = true;
  74. textBox3.Enabled = true;
  75. Buscar = textBox1.Text;
  76. }
  77. else
  78. {
  79. textBox2.Enabled = false;
  80. textBox3.Enabled = false;
  81. }
  82. dataGridView1.ReadOnly = true;
  83. }
  84.  
  85. private void textBox2_TextChanged(object sender, EventArgs e)
  86. {
  87. if (textBox2.Text.Length == 0)
  88. {
  89. textBox1.Enabled = true;
  90. textBox3.Enabled = true;
  91. Buscar = textBox2.Text;
  92. }
  93. else
  94. {
  95. textBox1.Enabled = false;
  96. textBox3.Enabled = false;
  97. }
  98. dataGridView1.ReadOnly = true;
  99. }
  100.  
  101. private void textBox3_TextChanged(object sender, EventArgs e)
  102. {
  103.  
  104. if (textBox3.Text.Length == 0)
  105. {
  106. textBox1.Enabled = true;
  107. textBox2.Enabled = true;
  108. Buscar = textBox3.Text;
  109. }
  110. else
  111. {
  112. textBox1.Enabled = false;
  113. textBox2.Enabled = false;
  114. }
  115. dataGridView1.ReadOnly = true;
  116. }
  117.  
  118. private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  119. {
  120. dataGridView1.ReadOnly = true;
  121. }
  122. }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement