Deliveries_FORM.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 Deliveries_FORM : Form
  14. {
  15. public Deliveries_FORM()
  16. {
  17. InitializeComponent();
  18. }
  19. private void Deliveries_FORM_Load(object sender, EventArgs e)
  20. {
  21. // TODO: данная строка кода позволяет загрузить данные в таблицу "gushchinaDataSet.Deliveries". При необходимости она может быть перемещена или удалена.
  22. this.deliveriesTableAdapter.Fill(this.gushchinaDataSet.Deliveries);
  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 button1_Click_1(object sender, EventArgs e)
  31. {
  32. listBindingSource.Filter = "[Артикул] LIKE'" + textBox2.Text + "%'";
  33. }
  34. private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
  35. {
  36. deliveriesTableAdapter.Update(gushchinaDataSet.Deliveries);
  37. }
  38. private void скачатьToolStripMenuItem_Click(object sender, EventArgs e)
  39. {
  40. Excel.Application exApp = new Excel.Application();
  41. exApp.Workbooks.Add();
  42. Excel.Worksheet wsh = (Excel.Worksheet)exApp.ActiveSheet;
  43. int i, j;
  44. wsh.Cells[1, 1] = "Артикул";
  45. wsh.Cells[1, 2] = "Наименование";
  46. wsh.Cells[1, 3] = "Цена";
  47. wsh.Cells[1, 4] = "Дата";
  48. for (i = 0; i <= DataGridView.RowCount - 2; i++)
  49. {
  50. for (j = 0; j <= DataGridView.ColumnCount - 1; j++)
  51. {
  52. wsh.Cells[i + 2, j + 1] = DataGridView[j, i].Value.ToString();
  53. }
  54. }
  55. exApp.Visible = true;
  56. }
  57. private void button4_Click(object sender, EventArgs e)
  58. {
  59. listBindingSource.Filter = "[Наименование] LIKE'" + comboBox1.Text + "%'";
  60. }
  61. private void button7_Click(object sender, EventArgs e)
  62. {
  63. listBindingSource.Filter = "[Дата] LIKE'" + textBox5.Text + "%'";
  64. }
  65. private void button2_Click(object sender, EventArgs e)
  66. {
  67. listBindingSource.Filter = "";
  68. }
  69. private void button3_Click(object sender, EventArgs e)
  70. {
  71. for (int i = 0; i < DataGridView.ColumnCount; i++)
  72. for (int j = 0; j < DataGridView.RowCount; j++)
  73. {
  74. DataGridView[i, j].Style.BackColor = Color.White;
  75. DataGridView[i, j].Style.ForeColor = Color.Black;
  76. }
  77. if (textBox2.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(textBox2.Text) > -1)
  83. {
  84. DataGridView[i, j].Style.BackColor = Color.Black;
  85. DataGridView[i, j].Style.ForeColor = Color.Red;
  86. }
  87. }
  88. if (comboBox1.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(comboBox1.Text) > -1)
  94. {
  95. DataGridView[i, j].Style.BackColor = Color.Black;
  96. DataGridView[i, j].Style.ForeColor = Color.Red;
  97. }
  98. }
  99. if (textBox4.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(textBox4.Text) > -1)
  105. {
  106. DataGridView[i, j].Style.BackColor = Color.Black;
  107. DataGridView[i, j].Style.ForeColor = Color.Red;
  108. }
  109. }
  110. if (textBox5.Text != "")
  111. {
  112. for (int i = 0; i < DataGridView.ColumnCount; i++)
  113. for (int j = 0; j < DataGridView.RowCount; j++)
  114. if (DataGridView[i, j].Value != null)
  115. if (DataGridView[i, j].Value.ToString().IndexOf(textBox5.Text) > -1)
  116. {
  117. DataGridView[i, j].Style.BackColor = Color.Black;
  118. DataGridView[i, j].Style.ForeColor = Color.Red;
  119. }
  120. }
  121. }
  122. }
  123. }