protected virtual void Page_Load(object sender, EventArgs e) { if (this.userid > 0) { if (CheckUserPopedoms("X")) { UserTypeList = Caches.GetUserTypeList(); Act = HTTPRequest.GetString("Act"); uName = Utils.ChkSQL(HTTPRequest.GetString("uName")); uPWD = Utils.ChkSQL(HTTPRequest.GetString("uPWD")); uPWD_Old = Utils.ChkSQL(HTTPRequest.GetString("uPWD_Old")); uPermissions = Utils.ChkSQL(HTTPRequest.GetString("uPermissions")); uEstate = Utils.ChkSQL(HTTPRequest.GetString("uEstate")); Erp_Name = Utils.ChkSQL(HTTPRequest.GetString("Erp_Name")); Erp_Pwd = Utils.ChkSQL(HTTPRequest.GetString("Erp_Pwd")); g_Name = Utils.ChkSQL(HTTPRequest.GetString("g_Name")); g_PWD = Utils.ChkSQL(HTTPRequest.GetString("g_PWD")); uType = HTTPRequest.GetInt("uType", 0); StaffID = HTTPRequest.GetInt("StaffID", 0); StorageIDStr = Utils.ChkSQL(HTTPRequest.GetString("StorageIDStr")); StorageIDStr = StorageIDStr.IndexOf("x") > -1 ? "x" : "," + StorageIDStr + ","; pi.Erp_Name = ""; pi.Erp_Pwd = ""; pi.g_Name = ""; pi.g_PWD = ""; if (Act == "Edit") { UserID = Utils.StrToInt(HTTPRequest.GetString("uid"), 0); ui = tbUserInfo.GetUserInfoModel(UserID); pi = tbUserInfo.GetUserPassportInfoModel(UserID); if (pi == null) { pi = new UserPassportInfo(); pi.Erp_Name = ""; pi.Erp_Pwd = ""; pi.g_Name = ""; pi.g_PWD = ""; } UserPopedomJson = UsersUtils.GetUserPopedomToJsonStr();// UsersUtils.GetUserPopedomToJsonStr(ui.uPermissions); } if (ispost) { if (ui.uPermissions != "X") { ui.uPermissions = uPermissions; } ui.uEstate = uEstate == "0" ? 0 : 1; ui.uType = uType; ui.StaffID = StaffID; ui.StorageIDStr = StorageIDStr; if (Act == "Add") { if (!tbUserInfo.ExistsUserInfo(uName)) { ui.uName = uName; ui.uPWD = Utils.MD5(uPWD); ui.uCode = Utils.CutString(Utils.GetRanDomCode(), 16); ui.uLastIP = HTTPRequest.GetIP(); ui.uAppendTime = DateTime.Now; ui.uUpAppendTime = DateTime.Now; pi.UserID = tbUserInfo.AddUserInfo(ui); Logs.AddEventLog(this.userid, "新增用户:" + ui.uName); if (pi.UserID > 0) { pi.Erp_Name = Erp_Name; pi.Erp_Pwd = Erp_Pwd; pi.g_Name = g_Name; pi.g_PWD = g_PWD; if (tbUserInfo.AddUserPassportInfo(pi) > 0) { AddMsgLine("创建成功!"); AddScript("window.setTimeout('window.parent.HidBox();',1000);"); } else { AddErrLine("账户创建成功,但通行证绑定失败!"); AddScript("history.back(1);"); } } else { AddErrLine("创建失败!"); AddScript("history.back(1);"); } } else { AddErrLine("用户名:" + uName + ",已存在,请更换!"); AddScript("history.back(1);"); } } if (Act == "Edit") { if (UserID > 0) { ui.UserID = UserID; if (uPWD.Trim() != "") { ui.uPWD = Utils.MD5(uPWD); } else { ui.uPWD = uPWD_Old; } //超级管理员无需修改权限与状态 if (ui.uPermissions == "X") { ui.uPermissions = "X"; ui.uEstate = 0; } try { pi.UserID = UserID; pi.Erp_Name = Erp_Name; pi.Erp_Pwd = Erp_Pwd; pi.g_Name = g_Name; pi.g_PWD = g_PWD; if (tbUserInfo.UserPassportInfoExists(UserID)) { tbUserInfo.UpdateUserPassportInfo(pi); } else { tbUserInfo.AddUserPassportInfo(pi); } tbUserInfo.UpdateUserInfo(ui); Logs.AddEventLog(this.userid, "修改用户:" + ui.uName); AddMsgLine("修改成功!"); AddScript("window.setTimeout('window.parent.HidBox();',1000);"); } catch (Exception ex) { AddErrLine("修改失败!<br/>" + ex); AddScript("window.setTimeout('window.parent.HidBox();',1000);"); } } else { AddErrLine("参数错误,修改失败!"); AddScript("window.setTimeout('window.parent.HidBox();',1000);"); } } } else { StorageList = tbStorageInfo.GetStorageInfoList(" sState = 0").Tables [0]; if (Act == "Add") { ui.UserID = 0; ui.uName = ""; ui.uPWD = ""; ui.uCode = ""; ui.uEstate = 0; ui.uPermissions = ""; ui.StorageIDStr = "x"; UserPopedomJson = UsersUtils.GetUserPopedomToJsonStr(); } if (Act == "Del") { try { tbUserInfo.DeleteUserInfo(HTTPRequest.GetString("uid")); Logs.AddEventLog(this.userid, "删除用户:uid=>" + HTTPRequest.GetString("uid")); AddMsgLine("删除成功!"); AddScript("window.setTimeout('window.parent.HidBox();',1000);"); } catch (Exception ex) { AddErrLine("删除失败!<br/>" + ex); AddScript("window.setTimeout('window.parent.HidBox();',1000);"); } } } } else { AddErrLine("权限不足!"); AddScript("window.parent.HidBox();"); } } else { AddErrLine("请先登录!"); SetBackLink("login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer())); SetMetaRefresh(1, "login.aspx?referer=" + Utils.UrlEncode(Utils.GetUrlReferrer())); } }
protected virtual void Page_Load(object sender, EventArgs e) { if (this.userid > 0) { if (CheckUserPopedoms("X")) { Classid = HTTPRequest.GetInt("Classid", 0); name = HTTPRequest.GetString("cName"); Popedoms = HTTPRequest.GetString("Popedoms"); Act = HTTPRequest.GetString("Act"); if (!ispost) { UserPopedomJson = UsersUtils.GetUserPopedomToJsonStr(); if (Act == "Edit") { if (Classid > 0) { DataTable UserTypeList = UsersUtils.GetUserType(); foreach (DataRow dr in UserTypeList.Rows) { if (Classid == int.Parse(dr["id"].ToString())) { name = dr["name"].ToString().Trim(); Popedoms = dr["Popedoms"].ToString().Trim(); break; } } } else { AddErrLine("参数错误!"); } } if (Act == "Del") { if (Classid > 0) { DataTable UserTypeList = UsersUtils.GetUserType(); foreach (DataRow dr in UserTypeList.Rows) { if (Classid == Convert.ToInt32(dr["id"].ToString())) { dr.Delete(); break; } } UserTypeList.AcceptChanges(); if (SaveDataToConfig(UserTypeList)) { Logs.AddEventLog(this.userid, "删除用户组"); AddMsgLine("删除成功"); AddScript("window.setTimeout('window.parent.HidBox();',3000);"); } } else { AddErrLine("参数错误!"); } } } else { if (Act == "Add") { DataTable UserTypeList = UsersUtils.GetUserType(); foreach (DataRow dr in UserTypeList.Rows) { if (name == dr["name"].ToString()) { AddErrLine("用户组:" + name + ",已经存在!无法添加!"); break; } } if (!IsErr()) { DataRow[] dr = UserTypeList.Select("", "id desc"); if (dr.Length > 0) { Classid = Convert.ToInt32(dr[0]["id"]) + 1; } DataRow _dr = UserTypeList.NewRow(); _dr["Name"] = name; _dr["ID"] = Classid; _dr["Popedoms"] = Popedoms; UserTypeList.Rows.Add(_dr); UserTypeList.AcceptChanges(); if (SaveDataToConfig(UserTypeList)) { Logs.AddEventLog(this.userid, "添加用户组"); AddMsgLine("添加成功"); AddScript("window.setTimeout('window.parent.HidBox();',3000);"); } } } if (Act == "Edit") { if (Classid > 0) { DataTable UserTypeList = UsersUtils.GetUserType(); foreach (DataRow dr in UserTypeList.Rows) { if (Classid != Convert.ToInt32(dr["id"].ToString())) { if (name == dr["name"].ToString()) { AddErrLine("用户组:" + name + ",已经存在!无法修改!"); break; } } } if (!IsErr()) { foreach (DataRow dr in UserTypeList.Rows) { if (Classid == Convert.ToInt32(dr["id"].ToString())) { dr["name"] = name; dr["Popedoms"] = Popedoms; } } UserTypeList.AcceptChanges(); if (SaveDataToConfig(UserTypeList)) { Logs.AddEventLog(this.userid, "修改用户组"); AddMsgLine("修改成功"); AddScript("window.setTimeout('window.parent.HidBox();',3000);"); } } } else { AddErrLine("参数错误!"); } } } } else { AddErrLine("权限不足!"); } } }