コード例 #1
0
        public void button3_Click(object sender, EventArgs e)//авторизация работника кухни
        {
            string           Login    = login.Text;
            string           Password = password.Text;
            ConnectDatabase  db       = new ConnectDatabase();
            DataTable        table    = new DataTable();
            MySqlDataAdapter adapter  = new MySqlDataAdapter();
            MySqlCommand     command  = new MySqlCommand("SELECT * FROM `cooks` WHERE `login` = @login AND `password` = @password", db.GetConnection());

            command.Parameters.Add("@login", MySqlDbType.VarChar).Value    = Login;
            command.Parameters.Add("@password", MySqlDbType.VarChar).Value = Password;
            adapter.SelectCommand = command;
            adapter.Fill(table);
            MySqlDataAdapter users = new MySqlDataAdapter($"Select role From cooks", db.GetConnection());

            role = Convert.ToString(table.Rows[0][5]);
            if (table.Rows.Count > 0)
            {
                ActiveForm.Hide();
                cookStartFormAfterRegistrationOrAuthorization csForm = new cookStartFormAfterRegistrationOrAuthorization();
                csForm.Show();
            }
            else
            {
                MessageBox.Show("No");
            }
        }
コード例 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            ConnectDatabase db = new ConnectDatabase();

            MySqlCommand command = new MySqlCommand("INSERT INTO `visitors` (`id`, `name`, `surname`, `thirdname`, `login`, `password`) VALUES (NULL, @name, @surname, @thirdname, @login, @password)", db.GetConnection());

            command.Parameters.Add("@login", MySqlDbType.VarChar).Value     = login.Text;
            command.Parameters.Add("@password", MySqlDbType.VarChar).Value  = password.Text;
            command.Parameters.Add("@name", MySqlDbType.VarChar).Value      = NName.Text;
            command.Parameters.Add("@surname", MySqlDbType.VarChar).Value   = Surname.Text;
            command.Parameters.Add("@thirdname", MySqlDbType.VarChar).Value = Thirdname.Text;

            db.OpenConnection();
            if (command.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("Учетная запись успешно создана!");
            }
            else
            {
                MessageBox.Show("Ошибка при создании учетной записи");
            }
            db.CloseConnection();

            ActiveForm.Hide();
            userAR user = new userAR();

            user.Show();
        }