123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using SD = System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Drawing.Printing;
- using System.Reflection;
- using Microsoft.Office.Interop.Excel;
- using System.Threading;
- using MySql.Data.MySqlClient;
- using Excel = Microsoft.Office.Interop.Excel;
- namespace IS_hairdresser
- {
- public partial class Purchase_FORM : Form
- {
- public Purchase_FORM()
- {
- InitializeComponent();
- }
- private void Purchase_FORM_Load(object sender, EventArgs e)
- {
- // TODO: данная строка кода позволяет загрузить данные в таблицу "gushchinaDataSet.Purchase". При необходимости она может быть перемещена или удалена.
- this.purchaseTableAdapter.Fill(this.gushchinaDataSet.Purchase);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- purchaseTableAdapter.Update(gushchinaDataSet.Purchase);
- }
- private void менюToolStripMenuItem_Click(object sender, EventArgs e)
- {
- Form1 frm = new Form1();
- this.Close();
- frm.Show();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- listBindingSource.Filter = "";
- }
- private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
- {
- listTableAdapter.Update(gushchinaDataSet.List);
- }
- private void button1_Click_1(object sender, EventArgs e)
- {
- listBindingSource.Filter = "[Артикул] LIKE'" + textBox2.Text + "%'";
- }
- private void button4_Click(object sender, EventArgs e)
- {
- listBindingSource.Filter = "[Наименование] LIKE'" + comboBox1.Text + "%'";
- }
- private void button5_Click(object sender, EventArgs e)
- {
- listBindingSource.Filter = "[Цена] LIKE'" + textBox3.Text + "%'";
- }
- private void button3_Click(object sender, EventArgs e)
- {
- for (int i = 0; i < dataGridView.ColumnCount; i++)
- for (int j = 0; j < dataGridView.RowCount; j++)
- {
- dataGridView[i, j].Style.BackColor = Color.White;
- dataGridView[i, j].Style.ForeColor = Color.Black;
- }
- if (textBox2.Text != "")
- {
- for (int i = 0; i < dataGridView.ColumnCount; i++)
- for (int j = 0; j < dataGridView.RowCount; j++)
- if (dataGridView[i, j].Value != null)
- if (dataGridView[i, j].Value.ToString().IndexOf(textBox2.Text) > -1)
- {
- dataGridView[i, j].Style.BackColor = Color.Black;
- dataGridView[i, j].Style.ForeColor = Color.Red;
- }
- }
- if (comboBox1.Text != "")
- {
- for (int i = 0; i < dataGridView.ColumnCount; i++)
- for (int j = 0; j < dataGridView.RowCount; j++)
- if (dataGridView[i, j].Value != null)
- if (dataGridView[i, j].Value.ToString().IndexOf(comboBox1.Text) > -1)
- {
- dataGridView[i, j].Style.BackColor = Color.Black;
- dataGridView[i, j].Style.ForeColor = Color.Red;
- }
- }
- if (textBox3.Text != "")
- {
- for (int i = 0; i < dataGridView.ColumnCount; i++)
- for (int j = 0; j < dataGridView.RowCount; j++)
- if (dataGridView[i, j].Value != null)
- if (dataGridView[i, j].Value.ToString().IndexOf(textBox3.Text) > -1)
- {
- dataGridView[i, j].Style.BackColor = Color.Black;
- dataGridView[i, j].Style.ForeColor = Color.Red;
- }
- }
- }
- private void скачатьToolStripMenuItem_Click(object sender, EventArgs e)
- {
- Excel.Application exApp = new Excel.Application();
- exApp.Workbooks.Add();
- Excel.Worksheet wsh = (Excel.Worksheet)exApp.ActiveSheet;
- int i, j;
- wsh.Cells[1, 1] = "Артикул";
- wsh.Cells[1, 2] = "Наименование";
- wsh.Cells[1, 3] = "Цена";
- wsh.Cells[1, 4] = "Количество";
- wsh.Cells[1, 5] = "Место хранения (Склад/Витрина)";
- for (i = 0; i <= dataGridView.RowCount - 2; i++)
- {
- for (j = 0; j <= dataGridView.ColumnCount - 1; j++)
- {
- wsh.Cells[i + 2, j + 1] = dataGridView[j, i].Value.ToString();
- }
- }
- exApp.Visible = true;
- }
- }
- }
|