12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.SqlClient;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using DllPass;
- namespace СУБД_Фабрика
- {
- public partial class FormReg : Form
- {
- public FormReg()
- {
- InitializeComponent();
- }
- private void FormReg_Load(object sender, EventArgs e)
- {
- // TODO: This line of code loads data into the 'sewingFactoryMURDataSet.Users' table. You can move, or remove it, as needed.
- this.usersTableAdapter.Fill(this.sewingFactoryMURDataSet.Users);
- }
- SqlConnection Con = new SqlConnection(FormMain.txtCon);
- private void BtnReg_Click(object sender, EventArgs e)
- {
- if (TbxFam.Text.Trim() == "" || TbxName.Text.Trim() == "" || TbxOtch.Text.Trim() == "" || TbxLog.Text.Trim() == "" || TbxPass.Text.Trim() == "")
- {
- MessageBox.Show("Не все поля заполнены", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if(MtbxPhone.Text.Length < 16)
- {
- MessageBox.Show("Некорректный номер телефона", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if(!CheckPass.Check(TbxPass.Text))
- {
- MessageBox.Show(@"Пароль должен отвечать следующим требованиям безопасности:
- длина пароля – минимум 6 символов;
- обязательно и строчные и прописные символы;
- цифр должно быть не более половины от всех символов пароля;
- должен содержать минимум 1 символ из набора: ! @ # $ % ^.
- ", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- BsUsers.Filter = $"Login = '{TbxLog.Text}'";
- if(BsUsers.Count > 0)
- {
- MessageBox.Show("Данный логин уже используется", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if(TbxPass.Text != TbxCheckPass.Text)
- {
- MessageBox.Show("Пароли не совпадают", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- Con.Open();
- string txtQuery = $"insert into Users(Login, Pass, Role, Fam, Name, Otch, Phone) values('{TbxLog.Text}','{TbxPass.Text}',1,'{TbxFam.Text}','{TbxName.Text}','{TbxOtch.Text}','{MtbxPhone.Text}')";
- SqlCommand query = new SqlCommand(txtQuery, Con);
- query.ExecuteNonQuery();
- Con.Close();
- MessageBox.Show("Вы успешно зарегестрированы", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information);
- Close();
- }
- private void CbxShowPass_CheckedChanged(object sender, EventArgs e)
- {
- TbxPass.UseSystemPasswordChar = !CbxShowPass.Checked;
- TbxCheckPass.UseSystemPasswordChar= !CbxShowPass.Checked;
- }
- }
- }
|