LIST_FORM.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 LIST_FORM : Form
  19. {
  20. public LIST_FORM()
  21. {
  22. InitializeComponent();
  23. }
  24. private void LIST_FORM_Load(object sender, EventArgs e)
  25. {
  26. // TODO: данная строка кода позволяет загрузить данные в таблицу "gushchinaDataSet1.List". При необходимости она может быть перемещена или удалена.
  27. this.listTableAdapter1.Fill(this.gushchinaDataSet1.List);
  28. }
  29. private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
  30. {
  31. listTableAdapter.Update(gushchinaDataSet.List);
  32. }
  33. private void скачатьToolStripMenuItem_Click(object sender, EventArgs e)
  34. {
  35. Excel.Application exApp = new Excel.Application();
  36. exApp.Workbooks.Add();
  37. Excel.Worksheet wsh = (Excel.Worksheet)exApp.ActiveSheet;
  38. int i, j;
  39. wsh.Cells[1, 1] = "Артикул";
  40. wsh.Cells[1, 2] = "Наименование";
  41. wsh.Cells[1, 3] = "Цена";
  42. wsh.Cells[1, 4] = "Количество";
  43. wsh.Cells[1, 5] = "Место хранения (Склад/Витрина)";
  44. for (i = 0; i <= listDataGridView.RowCount - 2; i++)
  45. {
  46. for (j = 0; j <= listDataGridView.ColumnCount - 1; j++)
  47. {
  48. wsh.Cells[i + 2, j + 1] = listDataGridView[j, i].Value.ToString();
  49. }
  50. }
  51. exApp.Visible = true;
  52. }
  53. private void менюToolStripMenuItem_Click_1(object sender, EventArgs e)
  54. {
  55. Form1 frm = new Form1();
  56. this.Close();
  57. frm.Show();
  58. }
  59. private void button1_Click_1(object sender, EventArgs e)
  60. {
  61. listBindingSource.Filter = "[Артикул] LIKE'" + textBox2.Text + "%'";
  62. }
  63. private void button4_Click(object sender, EventArgs e)
  64. {
  65. listBindingSource.Filter = "[Наименование] LIKE'" + comboBox1.Text + "%'";
  66. }
  67. private void button7_Click(object sender, EventArgs e)
  68. {
  69. listBindingSource.Filter = "[Место_хранения] LIKE'" + textBox5.Text + "%'";
  70. }
  71. private void button8_Click(object sender, EventArgs e)
  72. {
  73. listBindingSource.Filter = "";
  74. }
  75. private void button6_Click(object sender, EventArgs e)
  76. {
  77. for (int i = 0; i < listDataGridView.ColumnCount; i++)
  78. for (int j = 0; j < listDataGridView.RowCount; j++)
  79. {
  80. listDataGridView[i, j].Style.BackColor = Color.White;
  81. listDataGridView[i, j].Style.ForeColor = Color.Black;
  82. }
  83. if (textBox2.Text != "")
  84. {
  85. for (int i = 0; i < listDataGridView.ColumnCount; i++)
  86. for (int j = 0; j < listDataGridView.RowCount; j++)
  87. if (listDataGridView[i, j].Value != null)
  88. if (listDataGridView[i, j].Value.ToString().IndexOf(textBox2.Text) > -1)
  89. {
  90. listDataGridView[i, j].Style.BackColor = Color.Black;
  91. listDataGridView[i, j].Style.ForeColor = Color.Red;
  92. }
  93. }
  94. if (comboBox1.Text != "")
  95. {
  96. for (int i = 0; i < listDataGridView.ColumnCount; i++)
  97. for (int j = 0; j < listDataGridView.RowCount; j++)
  98. if (listDataGridView[i, j].Value != null)
  99. if (listDataGridView[i, j].Value.ToString().IndexOf(comboBox1.Text) > -1)
  100. {
  101. listDataGridView[i, j].Style.BackColor = Color.Black;
  102. listDataGridView[i, j].Style.ForeColor = Color.Red;
  103. }
  104. }
  105. if (textBox3.Text != "")
  106. {
  107. for (int i = 0; i < listDataGridView.ColumnCount; i++)
  108. for (int j = 0; j < listDataGridView.RowCount; j++)
  109. if (listDataGridView[i, j].Value != null)
  110. if (listDataGridView[i, j].Value.ToString().IndexOf(textBox3.Text) > -1)
  111. {
  112. listDataGridView[i, j].Style.BackColor = Color.Black;
  113. listDataGridView[i, j].Style.ForeColor = Color.Red;
  114. }
  115. }
  116. if (textBox4.Text != "")
  117. {
  118. for (int i = 0; i < listDataGridView.ColumnCount; i++)
  119. for (int j = 0; j < listDataGridView.RowCount; j++)
  120. if (listDataGridView[i, j].Value != null)
  121. if (listDataGridView[i, j].Value.ToString().IndexOf(textBox4.Text) > -1)
  122. {
  123. listDataGridView[i, j].Style.BackColor = Color.Black;
  124. listDataGridView[i, j].Style.ForeColor = Color.Red;
  125. }
  126. }
  127. if (textBox5.Text != "")
  128. {
  129. for (int i = 0; i < listDataGridView.ColumnCount; i++)
  130. for (int j = 0; j < listDataGridView.RowCount; j++)
  131. if (listDataGridView[i, j].Value != null)
  132. if (listDataGridView[i, j].Value.ToString().IndexOf(textBox5.Text) > -1)
  133. {
  134. listDataGridView[i, j].Style.BackColor = Color.Black;
  135. listDataGridView[i, j].Style.ForeColor = Color.Red;
  136. }
  137. }
  138. }
  139. }
  140. }