private void btnsubmit_Click(object sender, EventArgs e) { string username = txtusername.Text; string email = txtemail.Text; string password = SHA.petitsha(txtpass.Text); User.RoleType role = User.RoleType.EMPLOYE; if (cbrole.Text == "Employe") { role = User.RoleType.EMPLOYE; } else if (cbrole.Text == "Admin") { role = User.RoleType.ADMIN; } string sql = $"insert into admin (username,email ,pass, Role) Values ('{username}', '{email}','{password}', {User.roleTypeToInt(role)})"; if (DataBaseUtil.executeNonQuery(sql) > 0) { this.DialogResult = DialogResult.OK; } else { MessageBox.Show("User " + username + " exists already"); } }
public Journal(DateTime date, string username, User.RoleType role, bool etat) { this.date = date; this.username = username; this.role = role; this.etat = etat; }
private void load_admin() { lesadmins.Clear(); string sql = "Select * from admin"; MySqlDataReader rdr = DataBaseUtil.executeSelect(sql); while (rdr.Read()) { int roleid = int.Parse(rdr[4].ToString()); User.RoleType role = User.intToRoleType(roleid); User AdminViews = new User(int.Parse(rdr[0].ToString()), rdr[1].ToString(), rdr[2].ToString(), rdr[3].ToString(), role, bool.Parse(rdr[5].ToString())); lesadmins.Add(AdminViews); } rdr.Close(); //DGVAdmin.DataSource = null; DGVAdmin.DataSource = lesadmins; }