private void BindGridView()
        {
            cUser_group_menu objUserMenu        = new cUser_group_menu();
            DataSet          ds                 = new DataSet();
            string           strMessage         = string.Empty;
            string           strCriteria        = string.Empty;
            string           struser_group_code = cboUserGroup.SelectedValue;

            try
            {
                strCriteria  = " and user_group_code='" + struser_group_code + "' ";
                strCriteria += " And Menu_Status='Y' ";

                objUserMenu.SP_USER_GROUP_MENU_MANAGE_SEL(strCriteria, ref ds, ref strMessage);
                GridView1.DataSource = ds;
                GridView1.DataBind();

                cUser_group oUser_group = new cUser_group();
                string      strCheck    = string.Empty;
                strCheck = " and [user_group_code] = '" + struser_group_code + "' ";
                if (!oUser_group.SP_USER_GROUP_SEL(strCheck, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        string strScript =
                            "alert('ไม่สามารถบันข้อมูลได้ เนื่องจาก" +
                            "\\nไม่พบข้อมูล User Group : " + cboUserGroup.SelectedItem.Text + "');";
                        MsgBox(strScript);
                        return;
                    }
                    else
                    {
                        //this.myDirectorCode = ds.Tables[0].Rows[0]["director_code"].ToString();
                        this.myUnitCodeList        = ds.Tables[0].Rows[0]["unit_code_list"].ToString();
                        hddperson_group_list.Value = ds.Tables[0].Rows[0]["person_group_list"].ToString();
                        if (ds.Tables[0].Rows[0]["director_lock"].ToString().Equals("Y"))
                        {
                            chkdirector_lock.Checked = true;
                        }
                        else
                        {
                            chkdirector_lock.Checked = false;
                        }
                        if (ds.Tables[0].Rows[0]["unit_lock"].ToString().Equals("Y"))
                        {
                            chkunit_lock.Checked = true;
                        }
                        else
                        {
                            chkunit_lock.Checked = false;
                        }
                    }
                }

                if (GridView1.Rows.Count > 0)
                {
                    TabContainer1.Visible        = true;
                    TabContainer1.ActiveTabIndex = 0;
                    imgSaveOnly.Visible          = true;
                    chkdirector_lock.Visible     = true;
                    chkunit_lock.Visible         = true;
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                objUserMenu.Dispose();
                ds.Dispose();
            }
        }
Exemple #2
0
        protected void GenMenu()
        {
            cUser_group_menu objUserMenu = new cUser_group_menu();
            DataSet          ds          = new DataSet();
            DataTable        dtList      = new DataTable();
            DataTable        dt          = new DataTable();

            DataRow[] drMenu;
            DataRow[] drMenu_sub;
            try
            {
                Session["UserGroupCode"] = "001";
                string strCriteria = string.Empty;
                string strMassege  = string.Empty;
                strCriteria  = " And MenuParent = 0 ";
                strCriteria += " And Menu_Status='Y' ";
                strCriteria += " And user_group_code ='" + Session["UserGroupCode"].ToString() + "' ";
                strCriteria += " And CanView= 'Y' ";
                strCriteria += " Order by MenuOrder ";
                objUserMenu.SP_USER_GROUP_MENU_SEL(strCriteria, ref ds, ref strMassege);
                dtList = ds.Tables[0];

                strCriteria  = " And user_group_code ='" + Session["UserGroupCode"].ToString() + "' ";
                strCriteria += " And Menu_Status='Y' ";
                strCriteria += " And CanView= 'Y' ";
                strCriteria += " Order by MenuOrder ";
                objUserMenu.SP_USER_GROUP_MENU_SEL(strCriteria, ref ds, ref strMassege);
                dt = ds.Tables[0];

                ASPxMenu1.Items.Clear();
                for (int i = 0; i < dtList.Rows.Count; i++)
                {
                    DevExpress.Web.ASPxMenu.MenuItem menuItem = new DevExpress.Web.ASPxMenu.MenuItem();
                    menuItem.Text        = dtList.Rows[i]["MenuName"].ToString();
                    menuItem.NavigateUrl = dtList.Rows[i]["MenuNavigationUrl"].ToString();
                    menuItem.Image.Url   = Helper.CStr(dtList.Rows[i]["MenuImageUrl"].ToString());
                    drMenu = dt.Select("MenuParent=" + dtList.Rows[i]["MenuID"].ToString());
                    for (int j = 0; j < drMenu.Length; j++)
                    {
                        DevExpress.Web.ASPxMenu.MenuItem menuItem_sub = new DevExpress.Web.ASPxMenu.MenuItem();
                        menuItem_sub.Text        = drMenu[j]["MenuName"].ToString();
                        menuItem_sub.NavigateUrl = drMenu[j]["MenuNavigationUrl"].ToString();
                        menuItem_sub.Image.Url   = drMenu[j]["MenuImageUrl"].ToString();
                        drMenu_sub = dt.Select("MenuParent=" + drMenu[j]["MenuID"].ToString());
                        for (int k = 0; k < drMenu_sub.Length; k++)
                        {
                            DevExpress.Web.ASPxMenu.MenuItem menuItem_sub2 = new DevExpress.Web.ASPxMenu.MenuItem();
                            menuItem_sub2.Text        = drMenu_sub[k]["MenuName"].ToString();
                            menuItem_sub2.NavigateUrl = drMenu_sub[k]["MenuNavigationUrl"].ToString();
                            menuItem_sub2.Image.Url   = drMenu_sub[k]["MenuImageUrl"].ToString();
                            menuItem_sub.Items.Add(menuItem_sub2);
                        }
                        menuItem.Items.Add(menuItem_sub);
                    }
                    ASPxMenu1.Items.Add(menuItem);
                }
            }
            catch (Exception ex)
            {
                MsgBox(ex.Message);
            }
            finally
            {
                dtList.Dispose();
                objUserMenu.Dispose();
            }
        }
        private bool saveData(string struser_group_code)
        {
            bool   blnResult           = false;
            string strMessage          = string.Empty;
            string strActive           = string.Empty,
                   strCreatedBy        = string.Empty,
                   strUpdatedBy        = string.Empty;
            string           strScript = string.Empty;
            int              i;
            cUser_group_menu oUser_group_menu = new cUser_group_menu();
            cUser_group      oUser_group      = new cUser_group();
            DataSet          ds = new DataSet();

            try
            {
                string strCanView;
                string strCanInsert;
                string strCanEdit;
                string strCanDelete;
                string strCanApprove;
                string strCanExtra;
                oUser_group_menu.SP_USER_GROUP_MENU_DEL(struser_group_code, ref strMessage);
                for (i = 0; i <= (GridView1.Rows.Count - 1); i++)
                {
                    GridViewRow row           = GridView1.Rows[i];
                    HiddenField hddMenuID     = (HiddenField)row.FindControl("hddMenuID");
                    CheckBox    chkCanView    = (CheckBox)row.FindControl("chkCanView");
                    CheckBox    chkCanInsert  = (CheckBox)row.FindControl("chkCanInsert");
                    CheckBox    chkCanEdit    = (CheckBox)row.FindControl("chkCanEdit");
                    CheckBox    chkCanDelete  = (CheckBox)row.FindControl("chkCanDelete");
                    CheckBox    chkCanApprove = (CheckBox)row.FindControl("chkCanApprove");
                    CheckBox    chkCanExtra   = (CheckBox)row.FindControl("chkCanExtra");
                    string      intMenuId     = hddMenuID.Value;
                    strCanView    = chkCanView.Checked == true ? "Y" : "N";
                    strCanInsert  = chkCanInsert.Checked == true ? "Y" : "N";
                    strCanEdit    = chkCanEdit.Checked == true ? "Y" : "N";
                    strCanDelete  = chkCanDelete.Checked == true ? "Y" : "N";
                    strCanApprove = chkCanApprove.Checked == true ? "Y" : "N";
                    strCanExtra   = chkCanExtra.Checked == true ? "Y" : "N";
                    oUser_group_menu.SP_USER_GROUP_MENU_INS(struser_group_code, intMenuId, strCanView, strCanInsert, strCanEdit, strCanDelete, strCanApprove, strCanExtra, UserLoginName, ref strMessage);
                }
                string strperson_group_list = string.Empty;
                for (i = 0; i <= (GridView2.Rows.Count - 1); i++)
                {
                    GridViewRow row            = GridView2.Rows[i];
                    CheckBox    chkPersonGroup = (CheckBox)row.FindControl("chkPersonGroup");
                    if (chkPersonGroup.Checked)
                    {
                        Label lblperson_group_code = (Label)row.FindControl("lblperson_group_code");
                        strperson_group_list += lblperson_group_code.Text + ",";
                    }
                }
                if (strperson_group_list.Length > 0)
                {
                    strperson_group_list = strperson_group_list.Substring(0, strperson_group_list.Length - 1);
                }
                string strdirector_lock = "N";
                if (chkdirector_lock.Checked)
                {
                    strdirector_lock = "Y";
                }
                string strunit_lock = "N";
                if (chkunit_lock.Checked)
                {
                    strunit_lock = "Y";
                }
                oUser_group.SP_USER_GROUP_PERSON_GROUP_UPD(struser_group_code, strperson_group_list, strdirector_lock, strunit_lock, UserLoginName, ref strMessage);
                blnResult = true;
                MsgBox("บันทึกข้อมูลสมบูรณ์");
            }
            catch (Exception ex)
            {
                blnResult     = false;
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oUser_group_menu.Dispose();
            }
            return(blnResult);
        }