private void Lk_Load(object sender, EventArgs e) { connect DB = new connect(); MySqlCommand command = new MySqlCommand("SELECT `login`,`role` FROM `user_info` WHERE `id_user`=@id_user ", DB.getConnection()); command.Parameters.Add("@id_user", MySqlDbType.String).Value = User_info.id_user; DB.openConnection(); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { label7.Text = reader[0].ToString(); label8.Text = reader[1].ToString(); } reader.Close(); DB.closeConnection(); }
private void CheckOffline_CheckedChanged(object sender, EventArgs e) { dataGridView1.Rows.Clear(); connect DB = new connect(); var role = "Offline"; MySqlCommand command = new MySqlCommand("SELECT `login`,`role`,`reference` FROM `user_info` WHERE `id_user`!=@id_user AND role=@role", DB.getConnection()); command.Parameters.Add("@id_user", MySqlDbType.String).Value = User_info.id_user; command.Parameters.Add("@role", MySqlDbType.VarChar).Value = role; DB.openConnection(); MySqlDataReader reader = command.ExecuteReader(); List <string[]> data = new List <string[]>(); while (reader.Read()) { data.Add(new string[3]); data[data.Count - 1][0] = reader[0].ToString(); data[data.Count - 1][1] = reader[1].ToString(); data[data.Count - 1][2] = reader[2].ToString(); } reader.Close(); DB.closeConnection(); foreach (string[] s in data) { dataGridView1.Rows.Add(s); } }
private void btnSignUp_Click(object sender, EventArgs e) { if ((inputLogin.Text == "") || (InputLink.Text == "") || (InputPassword.Text == "")) { MessageBox.Show("Введите данные"); return; } if (radioButton1.Checked == false && radioButton2.Checked == false && radioButton3.Checked == false && radioButton4.Checked == false && radioButton5.Checked == false) { MessageBox.Show("Выберите роль"); return; } if (UserCheck() == true) { return; } var role = ""; if (radioButton1.Checked) { role = "Carry"; } if (radioButton2.Checked) { role = "Mid"; } if (radioButton3.Checked) { role = "Offline"; } if (radioButton4.Checked) { role = "Support"; } if (radioButton5.Checked) { role = "Hard Support"; } connect DB = new connect(); MySqlCommand command = new MySqlCommand("INSERT INTO `user_info`(`login`, `password`,`reference`,`role`) VALUES (@login,@password,@reference,@role)", DB.getConnection()); command.Parameters.Add("@login", MySqlDbType.VarChar).Value = inputLogin.Text; command.Parameters.Add("@password", MySqlDbType.VarChar).Value = InputPassword.Text; command.Parameters.Add("@reference", MySqlDbType.VarChar).Value = InputLink.Text; command.Parameters.AddWithValue("@role", role); DB.openConnection(); if (command.ExecuteNonQuery() == 1) { MessageBox.Show("Аккаунт успешно создан"); } else { MessageBox.Show("Аккаунт не создан"); } DB.closeConnection(); }