Warehouse_FORM.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using SD = System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Drawing.Printing;
  11. using System.Reflection;
  12. using Microsoft.Office.Interop.Excel;
  13. using System.Threading;
  14. using MySql.Data.MySqlClient;
  15. using Excel = Microsoft.Office.Interop.Excel;
  16. namespace IS_hairdresser
  17. {
  18. public partial class Warehouse_FORM : Form
  19. {
  20. public Warehouse_FORM()
  21. {
  22. InitializeComponent();
  23. }
  24. private void Warehouse_FORM_Load(object sender, EventArgs e)
  25. {
  26. // TODO: данная строка кода позволяет загрузить данные в таблицу "gushchinaDataSet.Warehouse". При необходимости она может быть перемещена или удалена.
  27. this.warehouseTableAdapter.Fill(this.gushchinaDataSet.Warehouse);
  28. }
  29. private void button1_Click(object sender, EventArgs e)
  30. {
  31. warehouseTableAdapter.Update(gushchinaDataSet.Warehouse);
  32. }
  33. private void менюToolStripMenuItem_Click(object sender, EventArgs e)
  34. {
  35. Form1 frm = new Form1();
  36. this.Close();
  37. frm.Show();
  38. }
  39. private void button2_Click(object sender, EventArgs e)
  40. {
  41. listBindingSource.Filter = "";
  42. }
  43. private void button1_Click_1(object sender, EventArgs e)
  44. {
  45. listBindingSource.Filter = "[Артикул] LIKE'" + textBox2.Text + "%'";
  46. }
  47. private void button3_Click(object sender, EventArgs e)
  48. {
  49. for (int i = 0; i < dataGridView.ColumnCount; i++)
  50. for (int j = 0; j < dataGridView.RowCount; j++)
  51. {
  52. dataGridView[i, j].Style.BackColor = Color.White;
  53. dataGridView[i, j].Style.ForeColor = Color.Black;
  54. }
  55. if (textBox2.Text != "")
  56. {
  57. for (int i = 0; i < dataGridView.ColumnCount; i++)
  58. for (int j = 0; j < dataGridView.RowCount; j++)
  59. if (dataGridView[i, j].Value != null)
  60. if (dataGridView[i, j].Value.ToString().IndexOf(textBox2.Text) > -1)
  61. {
  62. dataGridView[i, j].Style.BackColor = Color.Black;
  63. dataGridView[i, j].Style.ForeColor = Color.Red;
  64. }
  65. }
  66. if (comboBox1.Text != "")
  67. {
  68. for (int i = 0; i < dataGridView.ColumnCount; i++)
  69. for (int j = 0; j < dataGridView.RowCount; j++)
  70. if (dataGridView[i, j].Value != null)
  71. if (dataGridView[i, j].Value.ToString().IndexOf(comboBox1.Text) > -1)
  72. {
  73. dataGridView[i, j].Style.BackColor = Color.Black;
  74. dataGridView[i, j].Style.ForeColor = Color.Red;
  75. }
  76. }
  77. if (textBox4.Text != "")
  78. {
  79. for (int i = 0; i < dataGridView.ColumnCount; i++)
  80. for (int j = 0; j < dataGridView.RowCount; j++)
  81. if (dataGridView[i, j].Value != null)
  82. if (dataGridView[i, j].Value.ToString().IndexOf(textBox4.Text) > -1)
  83. {
  84. dataGridView[i, j].Style.BackColor = Color.Black;
  85. dataGridView[i, j].Style.ForeColor = Color.Red;
  86. }
  87. }
  88. if (textBox5.Text != "")
  89. {
  90. for (int i = 0; i < dataGridView.ColumnCount; i++)
  91. for (int j = 0; j < dataGridView.RowCount; j++)
  92. if (dataGridView[i, j].Value != null)
  93. if (dataGridView[i, j].Value.ToString().IndexOf(textBox5.Text) > -1)
  94. {
  95. dataGridView[i, j].Style.BackColor = Color.Black;
  96. dataGridView[i, j].Style.ForeColor = Color.Red;
  97. }
  98. }
  99. if (textBox1.Text != "")
  100. {
  101. for (int i = 0; i < dataGridView.ColumnCount; i++)
  102. for (int j = 0; j < dataGridView.RowCount; j++)
  103. if (dataGridView[i, j].Value != null)
  104. if (dataGridView[i, j].Value.ToString().IndexOf(textBox1.Text) > -1)
  105. {
  106. dataGridView[i, j].Style.BackColor = Color.Black;
  107. dataGridView[i, j].Style.ForeColor = Color.Red;
  108. }
  109. }
  110. }
  111. private void button4_Click(object sender, EventArgs e)
  112. {
  113. listBindingSource.Filter = "[Наименование] LIKE'" + comboBox1.Text + "%'";
  114. }
  115. private void button7_Click(object sender, EventArgs e)
  116. {
  117. listBindingSource.Filter = "[Дата] LIKE'" + comboBox1.Text + "%'";
  118. }
  119. private void button5_Click(object sender, EventArgs e)
  120. {
  121. listBindingSource.Filter = "[Сотрудник] LIKE'" + comboBox1.Text + "%'";
  122. }
  123. private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
  124. {
  125. listTableAdapter.Update(gushchinaDataSet.List);
  126. }
  127. private void скачатьToolStripMenuItem_Click(object sender, EventArgs e)
  128. {
  129. Excel.Application exApp = new Excel.Application();
  130. exApp.Workbooks.Add();
  131. Excel.Worksheet wsh = (Excel.Worksheet)exApp.ActiveSheet;
  132. int i, j;
  133. wsh.Cells[1, 1] = "Артикул";
  134. wsh.Cells[1, 2] = "Наименование";
  135. wsh.Cells[1, 3] = "Цена";
  136. wsh.Cells[1, 4] = "Количество";
  137. wsh.Cells[1, 5] = "Место хранения (Склад/Витрина)";
  138. for (i = 0; i <= dataGridView.RowCount - 2; i++)
  139. {
  140. for (j = 0; j <= dataGridView.ColumnCount - 1; j++)
  141. {
  142. wsh.Cells[i + 2, j + 1] = dataGridView[j, i].Value.ToString();
  143. }
  144. }
  145. exApp.Visible = true;
  146. }
  147. }
  148. }