123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Excel = Microsoft.Office.Interop.Excel;
- namespace СУБД_Фабрика
- {
- public partial class FormSpisMaterial : Form
- {
- public FormSpisMaterial()
- {
- InitializeComponent();
- }
- private void BtnExcel_Click(object sender, EventArgs e)
- {
- Excel.Application exapp = new Excel.Application();
- exapp.Visible = true;
- exapp.Workbooks.Open(Application.StartupPath + "\\Списание.xlsx", Type.Missing, true);
- Excel.Worksheet list1 = (exapp.Worksheets.get_Item(1));
- int RowExcel = 24;
- for (int i = 0; i <= DgvTkan.RowCount - 1; i++)
- {
- int CountSpis = 0;
- try
- {
- CountSpis = Convert.ToInt32(DgvTkan.Rows[i].Cells[3].Value);
- }
- catch { }
- if (CountSpis == 0)
- continue;
- list1.get_Range("A" + RowExcel).Value = DgvTkan.Rows[i].Cells[0].Value;
- list1.get_Range("H" + RowExcel).Value = "см";
- list1.get_Range("J" + RowExcel).Value = "ткань";
- list1.get_Range("L" + RowExcel).Value = CountSpis;
- int WidthTkan = Convert.ToInt32(DgvTkan.Rows[i].Cells[1].Value);
- list1.get_Range("N" + RowExcel).Value = CountSpis * WidthTkan;
- list1.get_Range("R" + RowExcel).Value = DgvTkan.Rows[i].Cells[4].Value;
- RowExcel++;
- }
- for (int i = 0; i <= DgvFurn.RowCount - 1; i++)
- {
- int CountSpis = 0;
- try
- {
- CountSpis = Convert.ToInt32(DgvFurn.Rows[i].Cells[2].Value);
- }
- catch { }
- if (CountSpis == 0)
- continue;
- list1.get_Range("A" + RowExcel).Value = DgvFurn.Rows[i].Cells[0].Value;
- list1.get_Range("H" + RowExcel).Value = "шт";
- list1.get_Range("J" + RowExcel).Value = "фурнитура";
- list1.get_Range("L" + RowExcel).Value = CountSpis;
- list1.get_Range("R" + RowExcel).Value = DgvFurn.Rows[i].Cells[3].Value;
- RowExcel++;
- }
- }
- private void FormSpisMaterial_Load(object sender, EventArgs e)
- {
- // TODO: This line of code loads data into the 'sewingFactoryMURDataSet1.Furnitura' table. You can move, or remove it, as needed.
- this.furnituraTableAdapter.Fill(this.sewingFactoryMURDataSet1.Furnitura);
- // TODO: This line of code loads data into the 'sewingFactoryMURDataSet1.Cloth' table. You can move, or remove it, as needed.
- this.clothTableAdapter.Fill(this.sewingFactoryMURDataSet1.Cloth);
- }
- private void BtnSpisMaterial_Click(object sender, EventArgs e)
- {
- DialogResult rez = MessageBox.Show("Вы уверены, что нужно выбранные материалы?",
- "Внимание!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (rez == DialogResult.No)
- return;
- for (int i = 0; i <= DgvTkan.RowCount - 1; i++)
- {
- int CountSpis = 0;
- try
- {
- CountSpis = Convert.ToInt32(DgvTkan.Rows[i].Cells[3].Value);
- }
- catch { }
- if (CountSpis == 0)
- continue;
- int LengthTkan = Convert.ToInt32(DgvTkan.Rows[i].Cells[2].Value);
- LengthTkan -= CountSpis;
- DgvTkan.Rows[i].Cells[2].Value = LengthTkan;
- }
- BsClothes.EndEdit();
- this.clothTableAdapter.Update(this.sewingFactoryMURDataSet1.Cloth);
- for (int i = 0; i <= DgvFurn.RowCount - 1; i++)
- {
- int CountSpis = 0;
- try
- {
- CountSpis = Convert.ToInt32(DgvFurn.Rows[i].Cells[2].Value);
- }
- catch { }
- if (CountSpis == 0)
- continue;
- int CountFur = Convert.ToInt32(DgvFurn.Rows[i].Cells[1].Value);
- CountFur -= CountSpis;
- DgvFurn.Rows[i].Cells[1].Value = CountFur;
- }
- BsFurn.EndEdit();
- this.furnituraTableAdapter.Update(this.sewingFactoryMURDataSet1.Furnitura);
- }
- }
- }
|