private void CreateNewRecipie_FormClosing(object sender, FormClosingEventArgs e) { CashierForm cf = (CashierForm)this.Owner; cf.Enabled = true; }
//Обраьотка авторизации private async void buttonLogin_Click(object sender, EventArgs e) { string sqlExpr = "SELECT * FROM dbo.Passwords"; string inputPassword = textBoxPassword.Text; string user; using (SqlConnection connection = new SqlConnection(connectToPasswords)) { await connection.OpenAsync(); if (connection.State == ConnectionState.Broken || connection.State == ConnectionState.Closed) { MessageBox.Show("Отсутствует подключение к БД."); Application.Exit(); } SqlCommand command = new SqlCommand(sqlExpr, connection); var reader = await command.ExecuteReaderAsync(); if (radioButtonCashier.Checked && comboBoxWorkers.SelectedIndex != -1) { await reader.ReadAsync(); string cashierPassword = reader.GetString(1); if (inputPassword == cashierPassword) { user = comboBoxWorkers.SelectedItem.ToString(); Hide(); CashierForm cf = new CashierForm(user); cf.Show(); } else { MessageBox.Show("Wrong password"); } } else { label2.Visible = true; } //Авторизация как Админ if (radioButtonAdmin.Checked) { label2.Visible = false; await reader.ReadAsync(); await reader.ReadAsync(); string adminPassword = reader.GetString(1); if (inputPassword == adminPassword) { //MessageBox.Show("Logined as admin"); Hide(); AdminForm af = new AdminForm(); af.Show(); } else { MessageBox.Show("Wrong password"); } } } }