Used_consumables_FORM.cs 6.8 KB

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