Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            FormAuthoriz formAuthoriz = new FormAuthoriz();

            formAuthoriz.Show();
            this.Hide();
        }
Beispiel #2
0
        private void btConect_Click(object sender, EventArgs e)
        {
            Registry_Class registry = new Registry_Class();

            registry.Registry_Set(cbIPServer.Text, cbDataSource.Text, cbInitialCatalog.Text, tbUserID.Text, tbPassword.Text);
            //((FormAuthoriz)Owner).FormAuthoriz_Load(sender, e);
            FormAuthoriz formAuthoriz = new FormAuthoriz();

            formAuthoriz.Show();
            DataBase_Configuration.logCon = true;
            Close();
        }
 private void buttonReg_Click(object sender, EventArgs e)
 {
     try
     {
         string Regist      = "INSERT INTO Accounts(Login_accounts, Password_accounts, Roles_id, Accounts_Logical_Delete) VALUES('" + textBoxLogin.Text + "', '" + cueTextBoxPassword.Text + "', 5, 0)";
         string CountLogin1 = "SELECT COUNT(Login_accounts) FROM Accounts WHERE Login_accounts = '" + textBoxLogin.Text + "'";
         string Emp         = "INSERT INTO Employee(Login_employee, Surname_employee, Name_employee, Patronymic_employee, Position_id, Employee_Logical_Delete) VALUES('" + textBoxLogin.Text + "', '" + textBoxFam.Text + "', '" + textBoxName.Text + "', '" + textBoxMiddleName.Text + "', '" + (comboBoxPosition.SelectedIndex + 1) + "', 0)";
         FormAuthoriz.sql.Open();
         SqlCommand cmdLogin1   = new SqlCommand(CountLogin1, FormAuthoriz.sql);
         SqlCommand cmdRegistr1 = new SqlCommand(Regist, FormAuthoriz.sql);
         SqlCommand cmdRegistr2 = new SqlCommand(Emp, FormAuthoriz.sql);
         int        count1      = Convert.ToInt32(cmdLogin1.ExecuteScalar());
         FormAuthoriz.sql.Close();
         if (cueTextBoxPassword.Text == textBoxReturnPassword.Text) //если пароль соответствует повторению
         {
             if (count1 > 0)                                        //если уже есть такой логин
             {
                 MessageBox.Show("Данная учётная запись уже существует");
             }
             else //если новый логин
             {
                 FormAuthoriz.sql.Open();
                 cmdRegistr1.ExecuteNonQuery();
                 cmdRegistr2.ExecuteNonQuery();
                 FormAuthoriz.sql.Close();
                 MessageBox.Show("Учетная запись успешно создана");
                 FormAuthoriz fa = new FormAuthoriz();
                 fa.Show();
                 this.Hide();
             }
         }
         else //если не соответствует
         {
             textBoxReturnPassword.BackColor = Color.BlueViolet;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Проверьте правильность заполнения полей", ex.ToString());
     }
 }