Ejemplo n.º 1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (this.IsValid)
            {
                IUserService service = ServiceFactory.GetService <IUserService>();

                UserInfo entity = null;

                if (this.IsInsert)
                {
                    entity = new UserInfo()
                    {
                        UserAccount  = this.txtUserAccount.Text.Trim(),
                        UserPwd      = this.txtUserPwd.Text.DESEncrypt(),
                        UserNickName = this.txtUserNickName.Text.Trim(),
                        UserEmail    = this.txtUserEmail.Text.Trim(),
                        UserPhone    = this.txtUserPhone.Text.Trim(),
                        UserStatus   = this.ddlUserStatus.SelectedValue.ToByte(0),
                        RoleId       = this.ddlUserRole.SelectedValue.ToByte(0),
                        OrgId        = this.hfOrgId.Value.ToInt(0)
                    };

                    if (service.CheckExists_Info(entity))
                    {
                        this.JscriptMsg("用户帐户已存在", null, "Error");

                        return;
                    }
                }

                else
                {
                    entity = service.GetObject_Info(this.PkId);

                    if (entity != null)
                    {
                        entity.UserPwd      = this.txtUserPwd.Text.DESEncrypt();
                        entity.UserNickName = this.txtUserNickName.Text.Trim();
                        entity.UserEmail    = this.txtUserEmail.Text.Trim();
                        entity.UserPhone    = this.txtUserPhone.Text.Trim();
                        entity.UserStatus   = this.ddlUserStatus.SelectedValue.ToByte(0);
                        entity.RoleId       = this.ddlUserRole.SelectedValue.ToByte(0);
                        entity.OrgId        = this.hfOrgId.Value.ToInt(0);
                    }
                }

                service.Save_Info(entity);

                if (this.IsInsert && (sender as Button).CommandName == "SubmitContinue")
                {
                    this.ReturnUrl = this.Request.Url.AbsolutePath;
                }

                this.JscriptMsg("数据保存成功", this.ReturnUrl, "Success");
            }

            UserConvert.ClearCache();
        }
Ejemplo n.º 2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            IUserService service = ServiceFactory.GetService <IUserService>();

            foreach (GridViewRow objGVR in this.gvList.Rows)
            {
                if (objGVR.RowType == DataControlRowType.DataRow)
                {
                    CheckBox cbSelect = objGVR.FindControl("cbSelect") as CheckBox;

                    if (cbSelect != null && cbSelect.Checked)
                    {
                        int pkId = this.gvList.DataKeys[objGVR.RowIndex]["PkId"].ToString().ToInt();

                        service.Delete_Info(pkId);
                    }
                }
            }

            this.JscriptMsg("数据删除成功", null, "Success");

            UserConvert.ClearCache();
        }
Ejemplo n.º 3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (this.IsValid)
            {
                IUserService service = ServiceFactory.GetService <IUserService>();

                UserRole entity = null;
                List <UserRolePermission> rolePermissionList = new List <UserRolePermission>();

                if (this.IsInsert)
                {
                    entity = new UserRole()
                    {
                        RoleName   = this.txtRoleName.Text.Trim(),
                        DataFilter = this.ddlDataFilter.SelectedValue.ToByte(0),
                        RoleStatus = this.ddlRoleStatus.SelectedValue.ToByte(0)
                    };

                    if (service.CheckExists_Role(entity))
                    {
                        this.JscriptMsg("角色名称已存在", null, "Error");

                        return;
                    }
                }

                else
                {
                    entity = service.GetObject_Role(this.PkId);

                    if (entity != null)
                    {
                        entity.DataFilter = this.ddlDataFilter.SelectedValue.ToByte(0);
                        entity.RoleStatus = this.ddlRoleStatus.SelectedValue.ToByte(0);
                    }
                }

                service.Save_Role(entity);

                foreach (TreeNode tnOne in this.tvPermission.Nodes)
                {
                    if (tnOne.Checked)
                    {
                        rolePermissionList.Add(new UserRolePermission()
                        {
                            RoleId = entity.PkId, PermCode = tnOne.Value
                        });
                    }

                    foreach (TreeNode tnTwo in tnOne.ChildNodes)
                    {
                        if (tnTwo.Checked)
                        {
                            rolePermissionList.Add(new UserRolePermission()
                            {
                                RoleId = entity.PkId, PermCode = tnTwo.Value
                            });
                        }
                    }
                }

                service.Delete_RolePermission(entity.PkId);
                service.Save_RolePermission(rolePermissionList);

                if (this.IsInsert && (sender as Button).CommandName == "SubmitContinue")
                {
                    this.ReturnUrl = this.Request.Url.AbsolutePath;
                }

                this.JscriptMsg("数据保存成功", this.ReturnUrl, "Success");
            }

            UserConvert.ClearCache();
        }