示例#1
0
        protected void storeDepGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName.Equals("Add"))
                {
                    UserRoleBLL sRoleManager = new UserRoleBLL();
                    TextBox     txtname      = (TextBox)storeDepGrid.FooterRow.FindControl("txtAddname");
                    TextBox     txtDesc      = (TextBox)storeDepGrid.FooterRow.FindControl("txtAddRDesc");
                    string      roleName     = (storeDepGrid.FooterRow.FindControl("ddlAddRoleName") as DropDownList).SelectedItem.Value;

                    UserRoles roleToAdd = new UserRoles();
                    roleToAdd.UserRoleName = txtname.Text;
                    roleToAdd.Description  = txtDesc.Text;
                    int res;
                    if (int.TryParse(roleName, out res))
                    {
                        roleToAdd.SystemRoleId = res;
                        sRoleManager.Add(roleToAdd);
                    }
                }
            }
            catch (Exception exp) { }
            finally
            {
                storeDepGrid.EditIndex = -1;
                BindGrid();
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (CEmpName.SelectedValue == "0")
            {
                lblEmpvalidation.Visible = true;
                CEmpName.Focus();
                return;
            }

            if (btnSave.Text == "Save")
            {
                DTO.EmpId      = Convert.ToInt32(CEmpName.SelectedValue);
                DTO.RoleId     = Convert.ToInt32(ddlRoleName.SelectedValue);
                DTO.CreateDate = System.DateTime.Now;
                DTO.CreateBy   = HttpContext.Current.User.Identity.Name;
                URBLL.Add(DTO);
            }
            else
            {
                DTO.UserRoleId = Convert.ToInt32(HFUserRoleId.Value);
                DTO.EmpId      = Convert.ToInt32(CEmpName.SelectedValue);
                DTO.RoleId     = Convert.ToInt32(ddlRoleName.SelectedValue);

                DTO.UpdateDate = System.DateTime.Now;
                DTO.UpdateBy   = HttpContext.Current.User.Identity.Name;
                URBLL.Edit(DTO);
                btnSave.Text = "Save";
            }
            pagingLoal();
            clearCntrol();
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (btnSave.Text == "Save")
            {
                DTO.EmpId      = Convert.ToInt32(ddlEmpName.SelectedValue);
                DTO.RoleId     = Convert.ToInt32(ddlRoleName.SelectedValue);
                DTO.CreateDate = System.DateTime.Now;
                DTO.CreateBy   = HttpContext.Current.User.Identity.Name;
                URBLL.Add(DTO);
            }
            else
            {
                // start log insert
                string Logfield = "";
                var    bb       = URBLL.LoadUserRole_linkbuttonEmpName_New_2(Convert.ToInt32(HFUserRoleId.Value), 0, 0);
                Logfield        = "UserRoleId-" + HFUserRoleId.Value + ";" + " Employee-" + ddlEmpName.SelectedItem + ";" + " Role-" + bb.First().RoleName.ToString() + "#" + ddlRoleName.SelectedItem + ";";
                LogDTO.LogField = Logfield;
                LogDTO.LogBy    = HttpContext.Current.User.Identity.Name;
                LogDTO.LogDate  = System.DateTime.Now;
                LogBLL.AddUserRole_Log(LogDTO);
                // end log insert

                DTO.UserRoleId = Convert.ToInt32(HFUserRoleId.Value);
                DTO.EmpId      = Convert.ToInt32(ddlEmpName.SelectedValue);
                DTO.RoleId     = Convert.ToInt32(ddlRoleName.SelectedValue);

                DTO.UpdateDate = System.DateTime.Now;
                DTO.UpdateBy   = HttpContext.Current.User.Identity.Name;
                URBLL.Edit(DTO);
                btnSave.Text = "Save";
            }
            pagingLoal();
            clearCntrol();
        }
示例#4
0
        protected void Save()
        {
            try
            {
                RoleId = int.Parse(this.txtRoleId.Value);
            }
            catch
            { }
            //if (this.txtRoleName.Value.ToString() == "清空此角色")
            //{
            //    Response.Write(CommonHelper.JumpBack("请选择角色!"));
            //    Response.End();
            //}

            int bFlag = 0;

            if (this.btnSave.Text == "修改角色")
            {
                UserRole model = new UserRole();
                if (this.txtRoleName.Value.ToString() == "清空此角色")
                {
                    model.IsDeleted = 1;
                }
                else
                {
                    model.IsDeleted = 0;
                }
                model.UserId   = UserId;
                model.RoleId   = RoleId;
                model.EditId   = LoginUserID;
                model.EditDate = DateTime.Now;
                bFlag          = userrolebll.UpdateRole(model);
                if (bFlag > 0)
                {
                    Response.Write(IFrameLayerClosetwo("修改角色成功!"));
                    Response.End();
                }
                else
                {
                    Response.Write(IFrameLayerClosetwo("修改角色失败"));
                    Response.End();
                }
            }
            else
            {
                UserRole model = new UserRole();
                model.UserId     = UserId;
                model.RoleId     = RoleId;
                model.CreateId   = LoginUserID;
                model.EditId     = LoginUserID;
                model.IsDeleted  = 0;
                model.CreateDate = DateTime.Now;
                model.EditDate   = DateTime.Now;
                int UserRoleIdNew = 0;
                UserRoleIdNew = userrolebll.Add(model);
                if (UserRoleIdNew > 0)
                {
                    Response.Write(IFrameLayerClosetwo("添加角色成功!"));
                    Response.End();
                }
                else
                {
                    Response.Write(IFrameLayerClosetwo("添加角色失败,继续添加!"));
                    Response.End();
                }
            }
        }