FormGetMaterial.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using Microsoft.Office.Interop.Excel;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Data.SqlClient;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace Швейная_фабрика
  13. {
  14. public partial class FormGetMaterial : Form
  15. {
  16. public FormGetMaterial()
  17. {
  18. InitializeComponent();
  19. }
  20. SqlConnection con = new SqlConnection("Data Source=213.155.192.79,3002;Initial Catalog=СlothesFactoryLG;Persist Security Info=True;User ID=u21lebed;Password=hgm8");
  21. private void FormGetMaterial_Load(object sender, EventArgs e)
  22. {
  23. // TODO: данная строка кода позволяет загрузить данные в таблицу "сlothesFactoryLGDataSet.Furnitura". При необходимости она может быть перемещена или удалена.
  24. this.furnituraTableAdapter.Fill(this.сlothesFactoryLGDataSet.Furnitura);
  25. // TODO: данная строка кода позволяет загрузить данные в таблицу "сlothesFactoryLGDataSet.Tkan". При необходимости она может быть перемещена или удалена.
  26. this.tkanTableAdapter.Fill(this.сlothesFactoryLGDataSet.Tkan);
  27. }
  28. private void TbxL_TextChanged(object sender, KeyPressEventArgs e)
  29. {
  30. if (!char.IsDigit(e.KeyChar))
  31. e.Handled = true;
  32. if ((Keys)e.KeyChar == Keys.Back || (Keys)e.KeyChar == Keys.Delete)
  33. e.Handled = false;
  34. }
  35. private void BtnSave_Click(object sender, EventArgs e)
  36. {
  37. if (TbxNameTkan.Text.Trim() != "" && TbxColor.Text.Trim() != "" && TbxComment.Text.Trim() != "" && TbxL.Text.Trim() != "" && TbxW.Text.Trim() != "")
  38. {
  39. string Queri = $@"Insert Into Color
  40. values ('{TbxColor.Text}')";
  41. con.Open();
  42. SqlCommand cmd = new SqlCommand(Queri, con);
  43. cmd.ExecuteNonQuery();
  44. con.Close();
  45. Queri = $"Select id_colors From Color where Title = '{TbxColor.Text}'";
  46. con.Open();
  47. cmd = new SqlCommand(Queri, con);
  48. SqlDataReader Rez = cmd.ExecuteReader();
  49. Rez.Read();
  50. ((DataRowView)BSTkan.Current)["id_color"] = Rez["id_colors"];
  51. con.Close();
  52. BSTkan.EndEdit();
  53. this.tkanTableAdapter.Update(this.сlothesFactoryLGDataSet.Tkan);
  54. }
  55. if (TbxNameFur.Text.Trim() != "" && TbxCountFur.Text.Trim() != "")
  56. {
  57. BSFurnitura.EndEdit();
  58. this.furnituraTableAdapter.Update(this.сlothesFactoryLGDataSet.Furnitura);
  59. }
  60. this.DialogResult = DialogResult.OK;
  61. this.Close();
  62. }
  63. }
  64. }