Consumables_sold_FORM.cs 7.1 KB

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