public static bool ChangePassword(string name, string oldpassword, string newpassword) { if (ValidateUser(name, oldpassword)) { User u = DBUserAdapter.LoadWithName(name); u.Login_password = GetMD5(newpassword); return(DBUserAdapter.Update(u)); } else { return(false); } }
private void mi_ok_Click(object sender, EventArgs e) { foreach (DataGridViewRow r in dgv.Rows) { if (!RowDataVerificate(r)) { MessageBox.Show("请您填写完整的信息"); r.Selected = true; return; } } foreach (DataGridViewRow r in dgv.Rows) { if (r.IsNewRow) { continue; } int id = 0; if (r.Cells[0].Value is Int32) { id = (int)(r.Cells[0].Value); } string lid = (string)(r.Cells[1].Value); string lpass = (string)(r.Cells[2].Value); string name = (string)(r.Cells[3].Value); string department = (string)(r.Cells[4].Value); User u = new User(id, lid, lpass, name, department); if (id == 0) { if (UserManager.Exist(name)) { MessageBox.Show("用户" + "\"" + name + "\"已经存在"); continue; } DBUserAdapter.Insert(u); } else { User ou = DBUserAdapter.LoadWithId(id); u.Level = ou.Level; DBUserAdapter.Update(u); } } }