private void saveChangesButton_Click(object sender, EventArgs e) { using (jPwdGenEntities userDb = new jPwdGenEntities()) { if (CheckAllTxtBox()) { Users user = new Users { LB_FNAME = fnameTextBox.Text, LB_LNAME = lnameTextBox.Text, LB_EMAIL = emailTextBox.Text, LB_PWD = pwdTextBox.Text, LB_USER = lnameTextBox.Text.ToLower() + "," + fnameTextBox.Text.ToLower(), //SUPER_USER = 0 }; userDb.Users.Add(user); userDb.SaveChanges(); } else { return; } } MessageBox.Show("Votre compte a été créé avec succès.", "Enregistrement", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); }
private void save_datas(PwdParamsView param, int idUser) { using (jPwdGenEntities pwdDb = new jPwdGenEntities()) { PwdUser pwdU = new PwdUser() { ID_USER = idUser, LB_PWD = pwd, LB_SOFT = param.softName }; pwdDb.PwdUser.Add(pwdU); pwdDb.SaveChanges(); } }
private void modifyButton_Click(object sender, EventArgs e) { int id = 0; if (MessageBox.Show("Etes-vous sur de vouloir changer les paramètres de ce mot de passe ?", "Avertissement", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { using (jPwdGenEntities newPwd = new jPwdGenEntities()) { id = int.Parse(idPwdTextBox.Text); PwdUser pwd = newPwd.PwdUser.FirstOrDefault(r => r.ID == id); pwd.LB_SOFT = selectedSoftTextBox.Text; pwd.LB_PWD = selectedPwdTextBox.Text; newPwd.SaveChanges(); } /*this.listView1.Clear(); * initData(listPwd);*/ } }
private void deletePwdButton_Click(object sender, EventArgs e) { if (MessageBox.Show( "Etes-vous sûr(e) de vouloir supprimer DEFINITIVEMENT ce mot de passe ?", "Avertissement", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { int id = int.Parse(idPwdTextBox.Text); using (jPwdGenEntities pwdUserDb = new jPwdGenEntities()) { PwdUser pwdDeleted = pwdUserDb.PwdUser.FirstOrDefault(r => r.ID == id); pwdDeleted.IS_ACTIVE = 0; pwdUserDb.SaveChanges(); } this.listView1.Clear(); /*foreach (ListViewItem item in listView1.Items) * listView1.Items.Clear();*/ initData(this.listPwd); } }