FSpisMaterial.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. namespace Фабрика
  11. {
  12. public partial class FSpisMaterial : Form
  13. {
  14. public FSpisMaterial()
  15. {
  16. InitializeComponent();
  17. }
  18. private void FSpisMaterial_Load(object sender, EventArgs e)
  19. {
  20. // TODO: данная строка кода позволяет загрузить данные в таблицу "dbFabrika2024DataSet.Furnitura". При необходимости она может быть перемещена или удалена.
  21. this.furnituraTableAdapter.Fill(this.dbFabrika2024DataSet.Furnitura);
  22. // TODO: данная строка кода позволяет загрузить данные в таблицу "dbFabrika2024DataSet.Tkani". При необходимости она может быть перемещена или удалена.
  23. this.tkaniTableAdapter.Fill(this.dbFabrika2024DataSet.Tkani);
  24. }
  25. private void tkaniBindingNavigatorSaveItem_Click(object sender, EventArgs e)
  26. {
  27. this.Validate();
  28. this.tkaniBindingSource.EndEdit();
  29. this.tableAdapterManager.UpdateAll(this.dbFabrika2024DataSet);
  30. }
  31. private void BtnSpisMaterial_Click(object sender, EventArgs e)
  32. {
  33. DialogResult rez = MessageBox.Show("Вы уверены, что нужно выбранные материалы?",
  34. "Внимание!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  35. if (rez == DialogResult.No)
  36. return;
  37. for (int i = 0; i <= DgvTkan.RowCount - 1; i++)
  38. {
  39. int CountSpis = 0;
  40. try
  41. {
  42. CountSpis = Convert.ToInt32(DgvTkan.Rows[i].Cells[3].Value);
  43. }
  44. catch { }
  45. if (CountSpis == 0)
  46. continue;
  47. int LengthTkan = Convert.ToInt32(DgvTkan.Rows[i].Cells[2].Value);
  48. LengthTkan -= CountSpis;
  49. DgvTkan.Rows[i].Cells[2].Value = LengthTkan;
  50. }
  51. tkaniBindingSource.EndEdit();
  52. this.tkaniTableAdapter.Update(this.dbFabrika2024DataSet.Tkani);
  53. for (int i = 0; i <= DgvFurnitura.RowCount - 1; i++)
  54. {
  55. int CountSpis = 0;
  56. try
  57. {
  58. CountSpis = Convert.ToInt32(DgvFurnitura.Rows[i].Cells[2].Value);
  59. }
  60. catch { }
  61. if (CountSpis == 0)
  62. continue;
  63. int CountFur = Convert.ToInt32(DgvFurnitura.Rows[i].Cells[1].Value);
  64. CountFur -= CountSpis;
  65. DgvFurnitura.Rows[i].Cells[1].Value = CountFur;
  66. }
  67. furnituraBindingSource.EndEdit();
  68. this.furnituraTableAdapter.Update(this.dbFabrika2024DataSet.Furnitura);
  69. }
  70. private void BtnToExcel_Click(object sender, EventArgs e)
  71. {
  72. MessageBox.Show("Документ сформирован");
  73. }
  74. private void BtnCancel_Click(object sender, EventArgs e)
  75. {
  76. DialogResult = DialogResult.Cancel;
  77. }
  78. }
  79. }