public int adduserinfo(string strdept, string strposition, string stremployee, string strname, string strtruename, string strpwd, string strpk_crop, DB_OPT opt) { UserModel model = new UserDal { BranchPK = strdept, RolePK = strposition, EmployeePK = stremployee, UserName = strname, TrueName = strtruename, Password = strpwd, pk_corp = strpk_crop }; return model.Add(opt); }
private void AddUser() { try { this.dbo = new DB_OPT(); this.dbo.Open(); if (((this.txtUserName.Text.Trim() == "") || (this.txtssbmpk.Value.Trim() == "")) || ((this.txtssgspk.Value.Trim() == "") || (this.txtssjspk.Value.Trim() == ""))) { Const.ShowMessage("带*的数据必须填写!", this.Page); } else { UserModel model = new UserDal { UserName = this.txtUserName.Text.Trim(), TrueName = this.txtTrueName.Text.Trim() }; if (model.ExistsByUserName(this.dbo) > 0) { Const.ShowMessage("用户名已经存在!", this.Page); } else { RoleModel model2 = new RoleDal { RolePK = this.txtssjspk.Value.Trim() }; model2 = model2.GetModel(false, false, this.dbo); BranchModel model3 = new BranchDal { BranchPK = this.txtssbmpk.Value.Trim() }; model3 = model3.GetModel(false, false, false, false, this.dbo); string str = PowerClass.SubTwoPower(this.PowerMenu1.GetPower(), model2.Power, "|"); model.Power = str; string str2 = PowerClass.SubTwoPower(this.PowerCompany1.GetPower(), model3.CompanyPower, "|"); model.CompanyPower = str2; model.BranchPK = this.txtssbmpk.Value.Trim(); model.RolePK = this.txtssjspk.Value.Trim(); if (this.txtPwd.Text.Trim() == "") { model.Password = QxRoom.QxConst.QxConst.Encrypt("123456", "powerich").Trim(); } else { model.Password = QxRoom.QxConst.QxConst.Encrypt(this.txtPwd.Text.Trim(), "powerich").Trim(); } model.pk_corp = this.txtssgspk.Value.Trim(); int count = 0; count = model.Add(this.dbo); if (base.Request["reload"] != null) { Const.AddSuccess(count, base.Request["reload"].ToString(), this.Page); } else { Const.AddSuccess(count, "", this.Page); } OperationLogBll.insertOp("新增", "用户列表", "在 " + this.txtssgs.Text.Trim() + " 单位 " + this.txtssbm.Text.Trim() + " 部门下新增用户名为:" + this.txtUserName.Text.Trim() + " 真实姓名为:" + this.txtTrueName.Text.Trim() + " 角色为:" + this.txtssjs.Text.Trim() + " 的用户,菜单权限为:" + this.PowerMenu1.GetPowerText() + " 管理范围为:" + this.PowerCompany1.GetPowerText(), "Y", this.Page); } } } catch (Exception exception) { this.el = new ExceptionLog.ExceptionLog(); this.el.ErrClassName = base.GetType().ToString(); this.el.ErrMessage = exception.Message.ToString(); this.el.ErrMethod = "AddUser()"; this.el.WriteExceptionLog(true); Const.OpenErrorPage("操作失败,请联系管理员!", this.Page); } finally { if (this.dbo != null) { this.dbo.Close(); } } }