Exemple #1
0
        protected void btnAddFunction_Click(object sender, EventArgs e)
        {
            var cmdFunc = new FunctionService();
            List<ROLE_FUNCTION> list = new List<ROLE_FUNCTION>();

            for (int i = 0; i < gridSelectFunction.Rows.Count; i++)
            {
                if (((CheckBox)gridSelectFunction.Rows[i].Cells[0].FindControl("check")).Checked)
                {
                    if (ViewState["RoleId"] != null && DataSouceRoleFunction.Where(x => x.FUNCTION_ID == Convert.ToInt32(gridSelectFunction.DataKeys[i].Value.ToString())).FirstOrDefault() == null)
                    {
                        ROLE_FUNCTION obj = new ROLE_FUNCTION();
                        obj.Action = ActionEnum.Create;
                        obj.ROLE_ID = Convert.ToInt32(ViewState["RoleId"].ToString());
                        obj.FUNCTION_ID = Convert.ToInt32(gridSelectFunction.DataKeys[i].Value.ToString());
                        obj.CREATE_DATE = DateTime.Now;
                        obj.CREATE_EMPLOYEE_ID = 0;
                        obj.UPDATE_DATE = DateTime.Now;
                        obj.UPDATE_EMPLOYEE_ID = 0;
                        obj.SYE_DEL = true;
                        list.Add(obj);
                    }
                    else if (DataSouceNewRoleFunction.Where(x => x.FUNCTION_ID == Convert.ToInt32(gridSelectFunction.DataKeys[i].Value.ToString())).FirstOrDefault() == null)
                    {
                        ROLE_FUNCTION obj = new ROLE_FUNCTION();
                        obj.Action = ActionEnum.Create;
                        obj.ROLE_ID = 0;
                        obj.FUNCTION_ID = Convert.ToInt32(gridSelectFunction.DataKeys[i].Value.ToString());
                        obj.CREATE_DATE = DateTime.Now;
                        obj.CREATE_EMPLOYEE_ID = 0;
                        obj.UPDATE_DATE = DateTime.Now;
                        obj.UPDATE_EMPLOYEE_ID = 0;
                        obj.SYE_DEL = true;
                        DataSouceNewRoleFunction.Add(obj);
                    }
                }
            }

            if (list.Count > 0)
            {
                var cmd = new RoleFunctionService(list);
                cmd.AddList();
            }

            InitialDataPopup();
            this.popup.Show();
        }
Exemple #2
0
 protected void gridFunction_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     var cmd = new RoleFunctionService();
     cmd.Delete(Convert.ToInt32(gridFunction.DataKeys[e.RowIndex].Values[0].ToString()));
     InitialDataPopup();
     this.popup.Show();
 }
Exemple #3
0
        private void InitialDataPopup()
        {
            if (ViewState["RoleId"] != null)
            {
                var cmd = new RoleService();
                _item = cmd.Select(Convert.ToInt32(ViewState["RoleId"].ToString()));
                if (_item != null)
                {
                    popTxtRoleCode.Text = _item.ROLE_CODE;
                    popTxtRoleName.Text = _item.ROLE_NAME;
                    flag.Text = "Edit";
                }

                var cmdFunc = new RoleFunctionService();
                DataSouceRoleFunction = cmdFunc.GetALLIncludeFunction(_item.ROLE_ID);
            }
            else
            {
                DataSouceRoleFunction = new List<ROLE_FUNCTION>();
            }
            DataSouceRoleFunction.AddRange(DataSouceNewRoleFunction);

            gridFunction.DataSource = DataSouceRoleFunction;
            gridFunction.DataBind();
        }
Exemple #4
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     var obj = new ROLE();
     obj.ROLE_CODE = popTxtRoleCode.Text;
     obj.ROLE_NAME = popTxtRoleName.Text;
     var cmd = new RoleService(obj);
     if (flag.Text.Equals("Add"))
     {
         obj.Action = ActionEnum.Create;
         obj.CREATE_DATE = DateTime.Now;
         obj.CREATE_EMPLOYEE_ID = 0;
         obj.UPDATE_DATE = DateTime.Now;
         obj.UPDATE_EMPLOYEE_ID = 0;
         obj.SYE_DEL = true;
         cmd.Add();
     }
     else
     {
         obj.Action = ActionEnum.Update;
         obj.ROLE_ID = Convert.ToInt32(ViewState["RoleId"].ToString());
         obj.UPDATE_DATE = DateTime.Now;
         obj.UPDATE_EMPLOYEE_ID = 0;
         obj.SYE_DEL = true;
         cmd.Edit();
     }
     if (DataSouceNewRoleFunction.Count > 0)
     {
         foreach (ROLE_FUNCTION item in DataSouceNewRoleFunction)
         {
             item.ROLE_ID = obj.ROLE_ID;
         }
         var cmdRoleFunction = new RoleFunctionService(DataSouceNewRoleFunction);
         cmdRoleFunction.AddList();
     }
     ViewState["RoleId"] = null;
     Response.Redirect("SearchRole.aspx");
 }