string UpdateData() { RDFNew.Module.Admin.Sys.Sys_User obj = new RDFNew.Module.Admin.Sys.Sys_User(); string Keyword = App_Com.Sys_User.GetUserInfo("UserID"); object[] data = obj.GetMaster(Keyword); if (data[0].ToString() == "0") //正常 { DataTable dt = data[1] as DataTable; if (dt.Rows.Count > 0) { DataRow dr; dr = dt.Rows[0]; if (App_Com.Helper.StringToSHA1Hash(this.txtPwd.Text) != (dr["Pwd"] == System.DBNull.Value ? "" : dr["Pwd"].ToString())) throw new Exception("您输入的原密码不正确."); if (this.txtPwdNew.Text.Trim()!=this.txtPwdCfg.Text.Trim()) throw new Exception("您输入的新密码不一致,请重新输入."); if (this.txtPwd.Text.Trim() == this.txtPwdNew.Text.Trim() && this.txtPwdNew.Text.Trim() == this.txtPwdCfg.Text.Trim()) throw new Exception("您输入的新密码不可与原密码相同,请重新输入."); dr["Pwd"] = App_Com.Helper.StringToSHA1Hash(this.txtPwdNew.Text); dr["ModBy"] = App_Com.Sys_User.GetUserInfo("UserID"); dr["ModOn"] = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); data = obj.ApplyMaster(dt.GetChanges(DataRowState.Modified), null, null, App_Com.Helper.BuildLog("Sys_User", "edit")); if (data[0].ToString() != "0") //正常 throw data[1] as Exception; else return data[1].ToString(); } else { throw new Exception("需要修改的记录已不存在,请刷新后再试."); } } else { throw data[1] as Exception; } }
public static object[] UserLogin(string UserID,string Pwd) { object[] rtn = new object[] {0,"登录成功." }; RDFNew.Module.Admin.Sys.Sys_User u = new RDFNew.Module.Admin.Sys.Sys_User(); object[] o=u.GetMaster(new RDFNew.Module.DALEntity.QuerySet(new List<RDFNew.Module.DALEntity.QueryInfo>(){ new RDFNew.Module.DALEntity.QueryInfo("And","(","","UserID","=","UserID",UserID), new RDFNew.Module.DALEntity.QueryInfo("Or","","","UserCode","=","UserCode",UserID), new RDFNew.Module.DALEntity.QueryInfo("Or","",")","Email","=","Email",UserID), })); if (o[0].ToString() == "0") { DataTable dt = o[1] as DataTable; if (dt.Rows.Count > 0) { if (dt.Select(" Enabled=1 ").Length > 0) { if (dt.Select(" IsNull(Pwd,'')='" + App_Com.Helper.StringToSHA1Hash(Pwd) + "'").Length > 0) { if (dt.Rows[0]["LoginTimes"] == System.DBNull.Value) dt.Rows[0]["LoginTimes"] = 0; dt.Rows[0]["LoginTimes"] = Convert.ToInt32(dt.Rows[0]["LoginTimes"]) + 1; dt.Rows[0]["LoginLast"] = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); RDFNew.Web.App_Com.Helper.SetSession(SYS_USER, dt); RDFNew.Web.App_Com.Helper.SetSession(SYS_USERMF, GetSys_UserMF(dt.Rows[0]["UserID"].ToString())); u.ApplyMaster(dt.GetChanges(DataRowState.Modified), null, null,App_Com.Helper.BuildLog("Sys_User", "login")); } else { rtn[0] = 1; rtn[1] = new Exception("登录密码不正确."); } } else { rtn[0] = 1; rtn[1] = new Exception("帐号未启用."); } } else { rtn[0] = 1; rtn[1] = new Exception("帐号不存在."); } } else { rtn[0] = 1; rtn[1] = o[1]; } return rtn; }
void LoadMater(string Keyword) { RDFNew.Module.Admin.Sys.Sys_User obj = new RDFNew.Module.Admin.Sys.Sys_User(); object[] data = obj.GetMaster(Keyword); if (data[0].ToString() == "0") //正常 { DataTable table = data[1] as DataTable; if (table.Rows.Count > 0) { this.txtUserID.Text = String.Format("{0}", table.Rows[0]["UserID"]); this.txtUserName.Text = String.Format("{0}", table.Rows[0]["UserName"]); this.txtNameE.Text = String.Format("{0}", table.Rows[0]["NameE"]); this.txtUserCode.Text = String.Format("{0}", table.Rows[0]["UserCode"]); this.txtEmail.Text = String.Format("{0}", table.Rows[0]["Email"]); } } else { Exception ex = data[1] as Exception; StringBuilder sb = new StringBuilder(); while (ex != null) { sb.Append(ex.Message + "\r\n"); ex = ex.InnerException; } Alert.Show("发生如下错误:\r\n" + sb.ToString(), MessageBoxIcon.Error); } }