FormEditUser.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 ImpulseVision
  11. {
  12. public partial class FormEditUser : Form
  13. {
  14. public FormEditUser()
  15. {
  16. InitializeComponent();
  17. }
  18. private void TbxPassportSeria_KeyPress(object sender, KeyPressEventArgs e)
  19. {
  20. e.Handled = true;
  21. if (e.KeyChar == (char)Keys.Back)
  22. {
  23. e.Handled = false;
  24. }
  25. if(char.IsDigit(e.KeyChar))
  26. {
  27. e.Handled = false;
  28. }
  29. }
  30. private void FormEditUser_Load(object sender, EventArgs e)
  31. {
  32. // TODO: This line of code loads data into the 'impulseVisionAppDataSet1.Users' table. You can move, or remove it, as needed.
  33. this.usersTableAdapter.Fill(this.impulseVisionAppDataSet1.Users);
  34. LblSelectUserID.Hide();
  35. BsUserInfo.Filter = $"ID = '{LblSelectUserID.Text.Trim()}'";
  36. }
  37. private void BtnSaveEditing_Click(object sender, EventArgs e)
  38. {
  39. BtnSaveEditing.DialogResult = DialogResult.None;
  40. if (TbxPassportSeria.Text.Trim().Length < 4)
  41. {
  42. MessageBox.Show("Серия паспорта не может быть короче 4-х чисел!", "ImpulseVision", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  43. return;
  44. }
  45. if (TbxPassportNumber.Text.Trim().Length < 6)
  46. {
  47. MessageBox.Show("Номер паспорта не может быть короче 6-ти чисел!", "ImpulseVision", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  48. return;
  49. }
  50. if (TbxPhone.Text.Trim().Length < 10)
  51. {
  52. MessageBox.Show("Номер телефона не может быть короче 10-ти чисел!", "ImpulseVision", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  53. return;
  54. }
  55. BtnSaveEditing.DialogResult = DialogResult.OK;
  56. BsUserInfo.EndEdit();
  57. this.usersTableAdapter.Update(this.impulseVisionAppDataSet1.Users);
  58. Close();
  59. }
  60. private void TbxPassportSeria_Validated(object sender, EventArgs e)
  61. {
  62. if (TbxPassportSeria.Text.Trim().Length > 4)
  63. {
  64. TbxPassportSeria.Text = TbxPassportSeria.Text.Trim().Substring(0, 4);
  65. }
  66. }
  67. private void TbxPassportNumber_Validated(object sender, EventArgs e)
  68. {
  69. if (TbxPassportNumber.Text.Trim().Length > 6)
  70. {
  71. TbxPassportNumber.Text = TbxPassportNumber.Text.Trim().Substring(0, 6);
  72. }
  73. }
  74. }
  75. }