FormReg.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. using PasswordCheckDll;
  11. namespace СУБД_Швейная_фабрика
  12. {
  13. public partial class FormReg : Form
  14. {
  15. public FormReg()
  16. {
  17. InitializeComponent();
  18. }
  19. private void FormReg_Load(object sender, EventArgs e)
  20. {
  21. // TODO: This line of code loads data into the 'db_22factoryDataSet1.Users' table. You can move, or remove it, as needed.
  22. this.usersTableAdapter.Fill(this.pracFabricaDataSet.Users);
  23. BsUsers.AddNew();
  24. LblRole.Text = "заказчик";
  25. roleTextBox.Text = "1";
  26. }
  27. private void BtnReg_Click(object sender, EventArgs e)
  28. {
  29. if (!PasswordCheckClass.PasswordCheck(PassTextBox.Text))
  30. {
  31. MessageBox.Show("Пароль не соответствует требованиям.", "Внимание!",
  32. MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  33. PassTextBox.Focus();
  34. return;
  35. }
  36. try
  37. {
  38. BsUsers.EndEdit();
  39. this.usersTableAdapter.Update(this.pracFabricaDataSet.Users);
  40. this.usersTableAdapter.Fill(this.pracFabricaDataSet.Users);
  41. }
  42. catch
  43. {
  44. MessageBox.Show(@"В базе данных уже есть пользователь с таким логином.
  45. Введите уникальный логин пользователя.", "Внимание!", MessageBoxButtons.OK,
  46. MessageBoxIcon.Exclamation);
  47. LoginTextBox.Focus();
  48. }
  49. this.DialogResult = DialogResult.OK;
  50. Close();
  51. }
  52. private void CbxShowPass_CheckedChanged(object sender, EventArgs e)
  53. {
  54. PassTextBox.UseSystemPasswordChar = !PassTextBox.UseSystemPasswordChar;
  55. }
  56. }
  57. }