bool IBLL.IOper.Login(string oper_id, string pwd, out string errMsg) { errMsg = ""; if (pwd != "") { Helper.sec sec = new Helper.sec(); pwd = sec.des(pwd); } string sql = "select * from sa_t_operator_i where oper_id='" + oper_id + "' and branch_no='" + Program.branch_no + "' "; var dt = Program.db.ExecuteToTable(sql, null); if (dt.Rows.Count > 0) { if (dt.Rows[0]["oper_pw"].ToString().ToUpper() != pwd.ToUpper()) { errMsg = "密码错误"; return(false); } if (dt.Rows[0]["oper_status"].ToString() != "1") { errMsg = "账号状态异常"; return(false); } Program.oper_id = oper_id; Program.oper_name = dt.Rows[0]["oper_name"].ToString(); Program.oper_type = dt.Rows[0]["oper_type"].ToString(); return(true); } errMsg = "账号或者密码错误"; return(false); }
public void ResetPWD(string oper_id, string new_pwd) { Helper.sec sec = new Helper.sec(); DB.IDB db = new DB.DBByAutoClose(Appsetting.conn); string sql = "update sa_t_operator_i set oper_pw='" + sec.des(new_pwd) + "' where oper_id='" + oper_id + "'"; db.ExecuteScalar(sql, null); }
void IBLL.IOper.ChangePWD(string oper_id, string old_pwd, string new_pwd) { string sql = "select * from sa_t_operator_i where oper_id='" + oper_id + "'"; DB.IDB db = new DB.DBByAutoClose(Appsetting.conn); var tb = db.ExecuteToTable(sql, null); if (tb.Rows.Count == 0) { throw new Exception("不存在用户" + oper_id); } else { var row = tb.Rows[0]; string db_pwd = row["oper_pw"].ToString(); if (db_pwd == "") { if (old_pwd == "") { Helper.sec sec = new Helper.sec(); sql = "update sa_t_operator_i set oper_pw='" + sec.des(new_pwd) + "' where oper_id='" + oper_id + "'"; db.ExecuteScalar(sql, null); } else { throw new Exception("旧密码不正确"); } } else { Helper.sec sec = new Helper.sec(); db_pwd = sec.des(db_pwd); if (old_pwd == db_pwd) { sql = "update sa_t_operator_i set oper_pw='" + sec.des(new_pwd) + "' where oper_id='" + oper_id + "'"; db.ExecuteScalar(sql, null); } else { throw new Exception("旧密码不正确"); } } } }
private void label14_Click(object sender, EventArgs e) { if (txt_pwd2.Text.Length == 0) { var frm = new MsgForm("请正确输入密码"); frm.ShowDialog(); txt_pwd2.Focus(); } else { try { IBLL.IClientBLL bll = new BLL.ClientBLL(); string old_pwd = txt_pwd1.Text; string pwd = txt_pwd2.Text; Helper.sec sec = new Helper.sec(); if (old_pwd != "") { old_pwd = sec.des(old_pwd); } if (pwd != "") { pwd = sec.des(pwd); } var res = bll.ChangePwd(Program.branch_no, Program.oper_id, old_pwd, pwd); if (res) { IBLL.IOper bll2 = new BLL.Oper(); bll2.UpdatePwd(Program.branch_no, Program.oper_id, pwd); var frm = new MsgForm("修改密码成功"); frm.ShowDialog(); this.DialogResult = DialogResult.OK; this.Close(); } } catch (Exception ex) { var frm = new MsgForm(ex.GetMessage()); frm.ShowDialog(); } } }
void IBLL.IOper.Login(string oper_id, string pwd, out string oper_name, out string oper_type) { string sql = "select * from sa_t_operator_i where oper_id='" + oper_id + "' and oper_status='1'"; DB.IDB db = new DB.DBByAutoClose(Appsetting.conn); var tb = db.ExecuteToTable(sql, null); if (tb.Rows.Count == 0) { throw new Exception("不存在用户" + oper_id); } else { var row = tb.Rows[0]; string db_pwd = row["oper_pw"].ToString(); if (db_pwd == "") { if (pwd == "") { oper_name = row["oper_name"].ToString(); oper_type = row["oper_type"].ToString(); } else { throw new Exception("密码不正确"); } } else { Helper.sec sec = new Helper.sec(); db_pwd = sec.des(db_pwd); if (pwd == db_pwd) { oper_name = row["oper_name"].ToString(); oper_type = row["oper_type"].ToString(); } else { throw new Exception("密码不正确"); } } } }