Purchase_FORM.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 Purchase_FORM : Form
  19. {
  20. public Purchase_FORM()
  21. {
  22. InitializeComponent();
  23. }
  24. private void Purchase_FORM_Load(object sender, EventArgs e)
  25. {
  26. // TODO: данная строка кода позволяет загрузить данные в таблицу "gushchinaDataSet.Purchase". При необходимости она может быть перемещена или удалена.
  27. this.purchaseTableAdapter.Fill(this.gushchinaDataSet.Purchase);
  28. }
  29. private void button1_Click(object sender, EventArgs e)
  30. {
  31. purchaseTableAdapter.Update(gushchinaDataSet.Purchase);
  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 сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
  44. {
  45. listTableAdapter.Update(gushchinaDataSet.List);
  46. }
  47. private void button1_Click_1(object sender, EventArgs e)
  48. {
  49. listBindingSource.Filter = "[Артикул] LIKE'" + textBox2.Text + "%'";
  50. }
  51. private void button4_Click(object sender, EventArgs e)
  52. {
  53. listBindingSource.Filter = "[Наименование] LIKE'" + comboBox1.Text + "%'";
  54. }
  55. private void button5_Click(object sender, EventArgs e)
  56. {
  57. listBindingSource.Filter = "[Цена] LIKE'" + textBox3.Text + "%'";
  58. }
  59. private void button3_Click(object sender, EventArgs e)
  60. {
  61. for (int i = 0; i < dataGridView.ColumnCount; i++)
  62. for (int j = 0; j < dataGridView.RowCount; j++)
  63. {
  64. dataGridView[i, j].Style.BackColor = Color.White;
  65. dataGridView[i, j].Style.ForeColor = Color.Black;
  66. }
  67. if (textBox2.Text != "")
  68. {
  69. for (int i = 0; i < dataGridView.ColumnCount; i++)
  70. for (int j = 0; j < dataGridView.RowCount; j++)
  71. if (dataGridView[i, j].Value != null)
  72. if (dataGridView[i, j].Value.ToString().IndexOf(textBox2.Text) > -1)
  73. {
  74. dataGridView[i, j].Style.BackColor = Color.Black;
  75. dataGridView[i, j].Style.ForeColor = Color.Red;
  76. }
  77. }
  78. if (comboBox1.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(comboBox1.Text) > -1)
  84. {
  85. dataGridView[i, j].Style.BackColor = Color.Black;
  86. dataGridView[i, j].Style.ForeColor = Color.Red;
  87. }
  88. }
  89. if (textBox3.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(textBox3.Text) > -1)
  95. {
  96. dataGridView[i, j].Style.BackColor = Color.Black;
  97. dataGridView[i, j].Style.ForeColor = Color.Red;
  98. }
  99. }
  100. }
  101. private void скачатьToolStripMenuItem_Click(object sender, EventArgs e)
  102. {
  103. Excel.Application exApp = new Excel.Application();
  104. exApp.Workbooks.Add();
  105. Excel.Worksheet wsh = (Excel.Worksheet)exApp.ActiveSheet;
  106. int i, j;
  107. wsh.Cells[1, 1] = "Артикул";
  108. wsh.Cells[1, 2] = "Наименование";
  109. wsh.Cells[1, 3] = "Цена";
  110. wsh.Cells[1, 4] = "Количество";
  111. wsh.Cells[1, 5] = "Место хранения (Склад/Витрина)";
  112. for (i = 0; i <= dataGridView.RowCount - 2; i++)
  113. {
  114. for (j = 0; j <= dataGridView.ColumnCount - 1; j++)
  115. {
  116. wsh.Cells[i + 2, j + 1] = dataGridView[j, i].Value.ToString();
  117. }
  118. }
  119. exApp.Visible = true;
  120. }
  121. }
  122. }