Example #1
0
        private void Save_GroupMenu(int Group_ID)
        {
            NguoidungDAL _usermenuDAL = new NguoidungDAL();
            UltilFunc    Ulti = new UltilFunc();
            bool         R_Edit = false, R_Del = false, R_Add = false;
            T_Chucnang   _objchucnang = new T_Chucnang();
            ChucnangDAL  _dalchucnang = new ChucnangDAL();

            _nhomnguoidungDAL.XoaChucnangNhomNguoidung(Group_ID);
            _usermenuDAL.DeleteFromT_UserMenuDynamic(" Ma_Nhom=" + Group_ID);
            foreach (DataGridItem m_Item in gdListMenu.Items)
            {
                System.Web.UI.HtmlControls.HtmlInputCheckBox chk_Select = (HtmlInputCheckBox)m_Item.FindControl("optSelect");

                HtmlInputCheckBox chkR_Add  = (HtmlInputCheckBox)m_Item.FindControl("chkR_Add");
                HtmlInputCheckBox chkR_Edit = (HtmlInputCheckBox)m_Item.FindControl("chkR_Edit");
                HtmlInputCheckBox chkR_Del  = (HtmlInputCheckBox)m_Item.FindControl("chkR_Del");
                HtmlInputCheckBox chkR_Pub  = (HtmlInputCheckBox)m_Item.FindControl("chkR_Pub");
                if (chk_Select != null && chk_Select.Checked)
                {
                    int Menu_ID = Convert.ToInt32(this.gdListMenu.DataKeys[m_Item.ItemIndex].ToString());
                    _objchucnang = _dalchucnang.GetOneFromT_ChucnangByID(Menu_ID);
                    if (chkR_Add != null && chkR_Add.Checked)
                    {
                        R_Add = true;
                    }
                    else
                    {
                        R_Add = false;
                    }
                    if (chkR_Edit != null && chkR_Edit.Checked)
                    {
                        R_Edit = true;
                    }
                    else
                    {
                        R_Edit = false;
                    }
                    if (chkR_Del != null && chkR_Del.Checked)
                    {
                        R_Del = true;
                    }
                    else
                    {
                        R_Del = false;
                    }
                    if (_objchucnang.Ma_Chucnang_Cha > 0)
                    {
                        _nhomnguoidungDAL.InsertT_GroupMenu(Menu_ID, Group_ID, R_Edit, R_Del, R_Add);
                        string _sqldelete = "delete from T_Nhom_Chucnang where Ma_Nhom=" + Group_ID + " and Ma_ChucNang=" + _objchucnang.Ma_Chucnang_Cha;
                        Ulti.ExecSql(_sqldelete);
                        _nhomnguoidungDAL.InsertT_GroupMenu(_objchucnang.Ma_Chucnang_Cha, Group_ID, R_Edit, R_Del, R_Add);
                    }
                    else
                    {
                        _nhomnguoidungDAL.InsertT_GroupMenu(Menu_ID, Group_ID, R_Edit, R_Del, R_Add);
                    }
                }
            }
        }