using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Threading;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/****************************************************************************************************************************
* Project Name    : TimeCheck                                 Started Date  : 22-Dec-2008
* Module          : User Groups                               Last Modified : 04-Jan-2008
* Programmer      : Christopher S
* Current Storage : \\Angler56\Projects\Inprogress\SCREEN1206\code\TimeCheck_Product\Time_AttendanceApp
* BackUp          :
****************************************************************************************************************************/
public partial class Masters_TA_UI_Master_UserGroups_AddRights : Base.BasePage
{
    #region VariableDeclaration
    ResourceManager rm;
    userRightsEventData objUserRight = new userRightsEventData();
    cls_Common objCommon = new cls_Common();
    DataSet ds = new DataSet();
    TableHeaderRow headerRow = new TableHeaderRow();
    Table configuration = new Table();
    // Create TableCell objects to contain 
    // the text for the header.

    int employeeId = 0;
    CultureInfo ci;
    bool isReportsExists = false;

    TableCell tcHeader = new TableCell();

    #endregion
    #region PageLoadEvents
    protected void Page_Init(object sender, EventArgs e)
    {
        //useful for maintaining viewstate in dynamic controls
        if (IsPostBack)
        {
            if (Session["Modules"] != null)
            {
                ds = (DataSet)Session["Modules"];
            }
            if (shouldCreateControl == true)
            {
                //table created and division details loaded
                generateControls();
            }
            objCommon.menu("Previlege", "21");
        }
    }
    protected override object SaveViewState()
    {
        //useful for maintaining viewstate in dynamic controls
        object[] state = new object[2];
        state[0] = base.SaveViewState();
        state[1] = shouldCreateControl;
        return state;
    }
    protected override void LoadViewState(object savedState)
    {
        //useful for maintaining viewstate in dynamic controls
        if (savedState != null)
        {
            object[] state = (object[])savedState;
            base.LoadViewState(state[0]);
            shouldCreateControl = (bool)state[1];
        }
    }
    //useful for maintaining viewstate in dynamic controls
    private static bool shouldCreateControl = false;
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking
        base.Page_Load(sender, e);
        //get the culture info to set the language        
        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        employeeId = Int32.Parse(Session["EmpAutoID"].ToString());
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        site.SiteMapProvider = Convert.ToString(Session["SiteMapProvider"]);
        // LoadStrings Function fills the Label from the Resource File
        
        #region script for client id
        //string strScript = "<script language='javascript' type='text/javascript'>";
        //strScript += " divMasterId = '" + divMaster.ClientID + "'";
        //strScript += " </script>";
        //this.RegisterStartupScript("setDivId", strScript);
        //string strScript1 = "<script language='javascript' type='text/javascript'>";
        //strScript1 += " divTranId = '" + divTransaction.ClientID + "'";
        //strScript1 += " </script>";
        //this.RegisterStartupScript("setTranId", strScript1);
        //string strScript2 = "<script language='javascript' type='text/javascript'>";
        //strScript2 += " divReportId = '" + divReports.ClientID + "'";
        //strScript2 += " </script>";
        //this.RegisterStartupScript("setReportId", strScript2);
        //string strScript3 = "<script language='javascript' type='text/javascript'>";
        //strScript3 += " divOSId = '" + divOS.ClientID + "'";
        //strScript3 += " </script>";
        //this.RegisterStartupScript("setOSId", strScript3);
        //string strScript4 = "<script language='javascript' type='text/javascript'>";
        //strScript4 += " divSSId = '" + divSS.ClientID + "'";
        //strScript4 += " </script>";
        //this.RegisterStartupScript("setSSId", strScript4);
        #endregion
        if (!IsPostBack)
        {
            LoadStrings(ci);
            Session["Modules"] = null;
            int gid;
            if (Request.QueryString["gid"] != null)
            {
                gid = Convert.ToInt16(Request.QueryString["gid"]);
                Session["gid"] = gid;
                DataSet dsusergroupName = new DataSet();
                dsusergroupName = objUserRight.getUserGroupNameById(gid);
                if (dsusergroupName != null)
                {
                    if (dsusergroupName.Tables.Count > 0)
                    {
                        if (dsusergroupName.Tables[0].Rows.Count > 0)
                        {
                            this.lblGroupName.Text = Convert.ToString(dsusergroupName.Tables[0].Rows[0]["groupName"]);
                        }
                    }
                }
                string strType = string.Empty;
                if (Session["Demo"] != null)
                {
                    if (Session["Demo"].ToString() == "Standard")
                    {
                        strType = "Standard";
                    }
                }
                // get page name               
                ds = objUserRight.GetPageName(strType);
                if (Session["Modules"] == null)
                {
                    Session["Modules"] = ds;
                }
                //  generates controls dynamically for first time page loading 
                generateControls();
                // get existing user rights status from database for respective user groups
                getRights(gid);
            }
        }
    }
    #endregion
    #region UserDefinedFunctions
    protected void GenerateMenu()
    {
        CultureInfo ci;
        Session["TopMenu"] = "";
        Session["MasterLeftMenu"] = "";
        Session["OrgLeftMenu"] = "";
        Session["ReportLeftMenu"] = "";
        Session["SystemLeftMenu"] = "";
        Session["TransLeftMenu"] = "";
        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        //Get Year Setting Details for Menu constructing and Year Setting Display
        cls_Common objClassCommon = new cls_Common();
        //if Standard Demo
        string strType = string.Empty;
        if (Session["Demo"] != null)
        {
            if (Session["Demo"].ToString() == "Standard")
            {
                strType = "Standard";
            }
        }
        //Top Menu
        cls_Common getmenu = new cls_Common();
        DataSet ds = new DataSet();
        Session["TopMenu"] = "<table border='0' cellpadding=0 cellspacing=0><tr><td width'10'>&nbsp;</td>";
        if (Convert.ToInt16(Session["userGroup_Id"]) != 0)
        {
            ds = getmenu.getUserMenu(0, Convert.ToInt16(Session["userGroup_Id"]), strType);
            for (int iloop = 0; iloop <= ds.Tables[0].Rows.Count - 1; iloop++)
            {
                String txt = ds.Tables[0].Rows[iloop]["displayName"].ToString();
                Session["TopMenu"] += "<td align='center'><a href='../" + ds.Tables[0].Rows[iloop]["path"] + "' title='" + rm.GetString(txt, ci) + " '>" + rm.GetString(txt, ci) + " </a></td>";
                if (iloop != ds.Tables[0].Rows.Count - 1)
                {
                    Session["TopMenu"] += "<td width='15' align='center'><span style='color:#888888'>|</span></td>";
                }
            }
        }
        Session["TopMenu"] += "</tr></table>";
        ds.Clear();
        ds.Dispose();
        //End of Top Menu
        //Master Left menu
        ds = getmenu.getUserMenu(1, Convert.ToInt16(Session["userGroup_Id"]), strType);
        Session["MasterLeftMenu"] = "<span class='LeftMenuHeader'>&nbsp;" + rm.GetString("Menu_Masters", ci) + "</span>";
        for (int iloop = 0; iloop <= ds.Tables[0].Rows.Count - 1; iloop++)
        {
            string txt = ds.Tables[0].Rows[iloop]["displayName"].ToString();
            Session["MasterLeftMenu"] += "<a class='leftMenu' href='" + ds.Tables[0].Rows[iloop]["path"] + "' title='" + rm.GetString(txt, ci) + " '>" + rm.GetString(txt, ci) + " </a>";
        }
        ds.Clear();
        ds.Dispose();
        //End of Master Left Menu
        //Transaction left menu
        ds = getmenu.getUserMenu(2, Convert.ToInt16(Session["userGroup_Id"]), strType);
        Session["TransLeftMenu"] = "<span class='LeftMenuHeader'>&nbsp;" + rm.GetString("Menu_Transactions", ci) + "</span>";
        for (int iloop = 0; iloop <= ds.Tables[0].Rows.Count - 1; iloop++)
        {
            string txt = ds.Tables[0].Rows[iloop]["displayName"].ToString();
            Session["TransLeftMenu"] += "<a class='leftMenu' href='" + ds.Tables[0].Rows[iloop]["path"] + "' title='" + rm.GetString(txt, ci) + " '>" + rm.GetString(txt, ci) + " </a>";
        }
        ds.Clear();
        ds.Dispose();
        //End of Transaction Left Menu
        //Report left menu
        ds = getmenu.getUserMenu(3, Convert.ToInt16(Session["userGroup_Id"]), strType);
        Session["ReportLeftMenu"] = "<span class='LeftMenuHeader'>&nbsp;" + rm.GetString("Menu_Reports", ci) + "</span>";
        for (int iloop = 0; iloop <= ds.Tables[0].Rows.Count - 1; iloop++)
        {
            string txt = ds.Tables[0].Rows[iloop]["displayName"].ToString();
            Session["ReportLeftMenu"] += "<a class='leftMenu' href='" + ds.Tables[0].Rows[iloop]["path"] + "' title='" + rm.GetString(txt, ci) + " '>" + rm.GetString(txt, ci) + " </a>";
        }
        ds.Clear();
        ds.Dispose();
        //End of Report Left Menu
        //Org setting left menu
        ds = getmenu.getUserMenu(4, Convert.ToInt16(Session["userGroup_Id"]), strType);
        Session["OrgLeftMenu"] = "<span class='LeftMenuHeader'>" + rm.GetString("Menu_Org_Settings", ci) + "</span>";
        for (int iloop = 0; iloop <= ds.Tables[0].Rows.Count - 1; iloop++)
        {
            string txt = ds.Tables[0].Rows[iloop]["displayName"].ToString();
            Session["OrgLeftMenu"] += "<a class='leftMenu' href='" + ds.Tables[0].Rows[iloop]["path"] + "' title='" + rm.GetString(txt, ci) + " '>" + rm.GetString(txt, ci) + " </a>";
        }
        ds.Clear();
        ds.Dispose();
        //End of Org Setting Left MEnu
        //Sys Setting left menu            
        ds = getmenu.getUserMenu(5, Convert.ToInt16(Session["userGroup_Id"]), strType);
        Session["SystemLeftMenu"] = "<span class='LeftMenuHeader'>&nbsp;" + rm.GetString("Menu_System_Settings", ci) + "</span>";
        for (int iloop = 0; iloop <= ds.Tables[0].Rows.Count - 1; iloop++)
        {
            string txt = ds.Tables[0].Rows[iloop]["displayName"].ToString();
            Session["SystemLeftMenu"] += "<a class='leftMenu' href='" + ds.Tables[0].Rows[iloop]["path"] + "' title='" + rm.GetString(txt, ci) + " '>" + rm.GetString(txt, ci) + " </a>";
        }
        ds.Clear();
        ds.Dispose();
        //End of Sys Setting Left Menu
    }
    /// <summary>
    /// user rights status are loaded from database and showed in UI
    /// </summary>
    /// <param name="val"></param>
    protected void getRights(int val)
    {
        DataSet dsExistingRights = new DataSet();
        dsExistingRights = objUserRight.getUserRights(val);
        if (dsExistingRights.Tables[0].Rows.Count > 0)
        {
            for (int i = 0; i < Panel1.Controls.Count - 1; i++)
            {
                Table table = (Table)Panel1.FindControl("MenuTable" + i);
                int k = 0;
                int headerPageid = 0;
                for (int j = 0; j < table.Rows.Count; j++)
                {
                    if (j == 0)
                    {
                        Label lblHeaderPageid = (Label)table.FindControl("lblHeaderPageid" + i);
                        if (lblHeaderPageid != null)
                        {
                            if (lblHeaderPageid.Text != "")
                            {
                                headerPageid = Convert.ToInt32(lblHeaderPageid.Text);
                            }
                        }
                        dsExistingRights.Tables[0].DefaultView.RowFilter = "pageId = '" + headerPageid + "'";
                        if (dsExistingRights.Tables[0].DefaultView.Count > 0)
                        {
                        }
                        else
                        {
                            CheckBox chkadd = (CheckBox)table.FindControl("chbHeaderadd" + i);
                            if (chkadd != null)
                            {
                                chkadd.Checked = false;
                            }
                            CheckBox chkview = (CheckBox)table.FindControl("chbHeaderView" + i);
                            if (chkview != null)
                            {
                                chkview.Checked = false;
                            }
                            CheckBox chkModify = (CheckBox)table.FindControl("chbHeaderModify" + i);
                            if (chkModify != null)
                            {
                                chkModify.Checked = false;
                            }
                            CheckBox chkDelete = (CheckBox)table.FindControl("chbHeaderDelete" + i);
                            if (chkDelete != null)
                            {
                                chkDelete.Checked = false;
                            }
                        }
                        k = 0;
                    }
                    else
                    {
                        Label lblHeaderPageid = (Label)table.FindControl("lblPageid" + i + k);
                        if (lblHeaderPageid != null)
                        {
                            if (lblHeaderPageid.Text != "")
                            {
                                headerPageid = Convert.ToInt32(lblHeaderPageid.Text);
                            }
                        }
                        dsExistingRights.Tables[0].DefaultView.RowFilter = "pageId = '" + headerPageid + "'";
                        if (dsExistingRights.Tables[0].DefaultView.Count > 0)
                        {
                            if ((dsExistingRights.Tables[0].DefaultView[0]["addPrv"].ToString().Contains("True")))
                            {
                                CheckBox chkadd = (CheckBox)table.FindControl("chbconfigAdd" + i + k);
                                if (chkadd != null)
                                {
                                    chkadd.Checked = true;
                                }
                            }
                            if ((dsExistingRights.Tables[0].DefaultView[0]["viewPrv"].ToString().Contains("True")))
                            {
                                CheckBox chkview = (CheckBox)table.FindControl("chbconfigView" + i + k);
                                if (chkview != null)
                                {
                                    chkview.Checked = true;
                                }
                            }
                            if ((dsExistingRights.Tables[0].DefaultView[0]["modifyPrv"].ToString().Contains("True")))
                            {
                                CheckBox chkModify = (CheckBox)table.FindControl("chbconfigModify" + i + k);
                                if (chkModify != null)
                                {
                                    chkModify.Checked = true;

                                }
                            }
                            if ((dsExistingRights.Tables[0].DefaultView[0]["deletePrv"].ToString().Contains("True")))
                            {
                                CheckBox chkDelete = (CheckBox)table.FindControl("chbconfigDelete" + i + k);
                                if (chkDelete != null)
                                {
                                    chkDelete.Checked = true;
                                }
                            }
                        }
                        else
                        {
                            CheckBox chkadd = (CheckBox)table.FindControl("chbconfigAdd" + i + k);
                            if (chkadd != null)
                            {
                                chkadd.Checked = true;
                            }
                            CheckBox chkview = (CheckBox)table.FindControl("chbconfigView" + i + k);
                            if (chkview != null)
                            {
                                chkview.Checked = true;
                            }
                            CheckBox chkModify = (CheckBox)table.FindControl("chbconfigModify" + i + k);
                            if (chkModify != null)
                            {
                                chkModify.Checked = true;
                            }
                            CheckBox chkDelete = (CheckBox)table.FindControl("chbconfigDelete" + i + k);
                            if (chkDelete != null)
                            {
                                chkDelete.Checked = true;
                            }
                        }
                        k += 1;
                    }
                }
            }
            //    #region status from database for master
            //    int m3 = 0;
            //    for (a = 0; a < masterCount - 1; a++)
            //    {
            //        ds.Tables[0].DefaultView.RowFilter = "parentId = '" + 189 + "'";
            //        if (ds.Tables[0].DefaultView.Count > 0)
            //        {
            //            while (m3 < masterCount - 1)
            //            {
            //                pageId1 = Convert.ToInt32(ds.Tables[0].DefaultView[m3]["pageId"].ToString());
            //                m3 += 1;
            //                break;
            //            }
            //        }
            //        ds.Tables[0].DefaultView.RowFilter = " ";
            //        dsExistingRights.Tables[0].DefaultView.RowFilter = "pageId = '" + pageId1 + "'";
            //        if (dsExistingRights.Tables[0].DefaultView.Count > 0)
            //        {
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["addPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox masterCb1 = new CheckBox();
            //                masterCb1 = (CheckBox)EmpManage.Rows[a].FindControl("chbEmpManage" + a + "1");
            //                masterCb1.Checked = true;
            //                if (dsExistingRights.Tables[0].DefaultView[0]["groupname"].ToString() == "SuperAdmin" && pageId1 == 21)
            //                {
            //                    masterCb1.Enabled = false;
            //                }
            //            }
            //            else
            //            {
            //                CheckBox masterCb1 = new CheckBox();
            //                masterCb1 = (CheckBox)EmpManage.Rows[a].FindControl("chbEmpManage" + a + "1");
            //                masterCb1.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["viewPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox masterCb2 = new CheckBox();
            //                masterCb2 = (CheckBox)EmpManage.Rows[a].FindControl("chbEmpManage" + a + "2");
            //                masterCb2.Checked = true;
            //                if (dsExistingRights.Tables[0].DefaultView[0]["groupname"].ToString() == "SuperAdmin" && pageId1 == 21)
            //                {
            //                    masterCb2.Enabled = false;
            //                }
            //            }
            //            else
            //            {
            //                CheckBox masterCb2 = new CheckBox();
            //                masterCb2 = (CheckBox)EmpManage.Rows[a].FindControl("chbEmpManage" + a + "2");
            //                masterCb2.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["modifyPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox masterCb3 = new CheckBox();
            //                masterCb3 = (CheckBox)EmpManage.Rows[a].FindControl("chbEmpManage" + a + "3");
            //                masterCb3.Checked = true;
            //                if (dsExistingRights.Tables[0].DefaultView[0]["groupname"].ToString() == "SuperAdmin" && pageId1 == 21)
            //                {
            //                    masterCb3.Enabled = false;
            //                }
            //            }
            //            else
            //            {
            //                CheckBox masterCb3 = new CheckBox();
            //                masterCb3 = (CheckBox)EmpManage.Rows[a].FindControl("chbEmpManage" + a + "3");
            //                masterCb3.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["deletePrv"].ToString().Contains("True")))
            //            {
            //                CheckBox masterCb4 = new CheckBox();
            //                masterCb4 = (CheckBox)EmpManage.Rows[a].FindControl("chbEmpManage" + a + "4");
            //                masterCb4.Checked = true;
            //                if (dsExistingRights.Tables[0].DefaultView[0]["groupname"].ToString() == "SuperAdmin" && pageId1 == 21)
            //                {
            //                    masterCb4.Enabled = false;
            //                }
            //            }
            //            else
            //            {
            //                CheckBox masterCb4 = new CheckBox();
            //                masterCb4 = (CheckBox)EmpManage.Rows[a].FindControl("chbEmpManage" + a + "4");
            //                masterCb4.Checked = false;
            //            }
            //            dsExistingRights.Tables[0].DefaultView.RowFilter = " ";
            //        }
            //        else
            //        {
            //            CheckBox masterCb1 = new CheckBox();
            //            masterCb1 = (CheckBox)EmpManage.Rows[a].FindControl("chbEmpManage" + a + "1");
            //            masterCb1.Checked = false;
            //            CheckBox masterCb2 = new CheckBox();
            //            masterCb2 = (CheckBox)EmpManage.Rows[a].FindControl("chbEmpManage" + a + "2");
            //            masterCb2.Checked = false;
            //            CheckBox masterCb3 = new CheckBox();
            //            masterCb3 = (CheckBox)EmpManage.Rows[a].FindControl("chbEmpManage" + a + "3");
            //            masterCb3.Checked = false;
            //            CheckBox masterCb4 = new CheckBox();
            //            masterCb4 = (CheckBox)EmpManage.Rows[a].FindControl("chbEmpManage" + a + "4");
            //            masterCb4.Checked = false;
            //        }
            //    }
            //    #endregion
            //    #region status from database for transaction
            //    int t3 = 0;
            //    for (b = 0; b < transactionCount - 1; b++)
            //    {
            //        ds.Tables[0].DefaultView.RowFilter = "parentId = '" + 187 + "'";
            //        if (ds.Tables[0].DefaultView.Count > 0)
            //        {
            //            while (t3 < transactionCount - 1)
            //            {
            //                pageId2 = Convert.ToInt32(ds.Tables[0].DefaultView[t3]["pageId"].ToString());
            //                t3 += 1;
            //                break;
            //            }
            //        }
            //        ds.Tables[0].DefaultView.RowFilter = " ";
            //        dsExistingRights.Tables[0].DefaultView.RowFilter = "pageId = '" + pageId2 + "'";
            //        if (dsExistingRights.Tables[0].DefaultView.Count > 0)
            //        {
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["addPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox transactionCb1 = new CheckBox();
            //                transactionCb1 = (CheckBox)devManage.Rows[b].FindControl("chbdevManage" + b + "1");
            //                transactionCb1.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox transactionCb1 = new CheckBox();
            //                transactionCb1 = (CheckBox)devManage.Rows[b].FindControl("chbdevManage" + b + "1");
            //                transactionCb1.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["viewPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox transactionCb2 = new CheckBox();
            //                transactionCb2 = (CheckBox)devManage.Rows[b].FindControl("chbdevManage" + b + "2");
            //                transactionCb2.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox transactionCb2 = new CheckBox();
            //                transactionCb2 = (CheckBox)devManage.Rows[b].FindControl("chbdevManage" + b + "2");
            //                transactionCb2.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["modifyPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox transactionCb3 = new CheckBox();
            //                transactionCb3 = (CheckBox)devManage.Rows[b].FindControl("chbdevManage" + b + "3");
            //                transactionCb3.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox transactionCb3 = new CheckBox();
            //                transactionCb3 = (CheckBox)devManage.Rows[b].FindControl("chbdevManage" + b + "3");
            //                transactionCb3.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["deletePrv"].ToString().Contains("True")))
            //            {
            //                CheckBox transactionCb4 = new CheckBox();
            //                transactionCb4 = (CheckBox)devManage.Rows[b].FindControl("chbdevManage" + b + "4");
            //                transactionCb4.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox transactionCb4 = new CheckBox();
            //                transactionCb4 = (CheckBox)devManage.Rows[b].FindControl("chbdevManage" + b + "4");
            //                transactionCb4.Checked = false;
            //            }
            //            dsExistingRights.Tables[0].DefaultView.RowFilter = " ";
            //        }
            //        else
            //        {
            //            CheckBox transactionCb1 = new CheckBox();
            //            transactionCb1 = (CheckBox)devManage.Rows[b].FindControl("chbdevManage" + b + "1");
            //            transactionCb1.Checked = false;
            //            CheckBox transactionCb2 = new CheckBox();
            //            transactionCb2 = (CheckBox)devManage.Rows[b].FindControl("chbdevManage" + b + "2");
            //            transactionCb2.Checked = false;
            //            CheckBox transactionCb3 = new CheckBox();
            //            transactionCb3 = (CheckBox)devManage.Rows[b].FindControl("chbdevManage" + b + "3");
            //            transactionCb3.Checked = false;
            //            CheckBox transactionCb4 = new CheckBox();
            //            transactionCb4 = (CheckBox)devManage.Rows[b].FindControl("chbdevManage" + b + "4");
            //            transactionCb4.Checked = false;
            //        }
            //    }
            //    #endregion
            //    #region status from database for report
            //    int r3 = 0;
            //    for (c = 0; c < reportCount - 1; c++)
            //    {
            //        ds.Tables[0].DefaultView.RowFilter = "parentId = '" + 188 + "'";
            //        if (ds.Tables[0].DefaultView.Count > 0)
            //        {
            //            while (r3 < reportCount - 1)
            //            {
            //                pageId3 = Convert.ToInt32(ds.Tables[0].DefaultView[r3]["pageId"].ToString());
            //                r3 += 1;
            //                break;
            //            }
            //        }
            //        ds.Tables[0].DefaultView.RowFilter = " ";
            //        dsExistingRights.Tables[0].DefaultView.RowFilter = "pageId = '" + pageId3 + "'";
            //        if (dsExistingRights.Tables[0].DefaultView.Count > 0)
            //        {
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["addPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox reportCb1 = new CheckBox();
            //                reportCb1 = (CheckBox)report.Rows[c].FindControl("chbReport" + c + "1");
            //                reportCb1.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox reportCb1 = new CheckBox();
            //                reportCb1 = (CheckBox)report.Rows[c].FindControl("chbReport" + c + "1");
            //                reportCb1.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["viewPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox reportCb2 = new CheckBox();
            //                reportCb2 = (CheckBox)report.Rows[c].FindControl("chbReport" + c + "2");
            //                reportCb2.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox reportCb2 = new CheckBox();
            //                reportCb2 = (CheckBox)report.Rows[c].FindControl("chbReport" + c + "2");
            //                reportCb2.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["modifyPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox reportCb3 = new CheckBox();
            //                reportCb3 = (CheckBox)report.Rows[c].FindControl("chbReport" + c + "3");
            //                reportCb3.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox reportCb3 = new CheckBox();
            //                reportCb3 = (CheckBox)report.Rows[c].FindControl("chbReport" + c + "3");
            //                reportCb3.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["deletePrv"].ToString().Contains("True")))
            //            {
            //                CheckBox reportCb4 = new CheckBox();
            //                reportCb4 = (CheckBox)report.Rows[c].FindControl("chbReport" + c + "4");
            //                reportCb4.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox reportCb4 = new CheckBox();
            //                reportCb4 = (CheckBox)report.Rows[c].FindControl("chbReport" + c + "4");
            //                reportCb4.Checked = false;
            //            }
            //            dsExistingRights.Tables[0].DefaultView.RowFilter = " ";
            //        }
            //        else
            //        {
            //            CheckBox reportCb1 = new CheckBox();
            //            reportCb1 = (CheckBox)report.Rows[c].FindControl("chbReport" + c + "1");
            //            reportCb1.Checked = false;
            //            CheckBox reportCb2 = new CheckBox();
            //            reportCb2 = (CheckBox)report.Rows[c].FindControl("chbReport" + c + "2");
            //            reportCb2.Checked = false;
            //            CheckBox reportCb3 = new CheckBox();
            //            reportCb3 = (CheckBox)report.Rows[c].FindControl("chbReport" + c + "3");
            //            reportCb3.Checked = false;
            //            CheckBox reportCb4 = new CheckBox();
            //            reportCb4 = (CheckBox)report.Rows[c].FindControl("chbReport" + c + "4");
            //            reportCb4.Checked = false;
            //        }
            //    }
            //    #endregion
            //    #region status from database for organization setting
            //    int o3 = 0;
            //    for (d = 0; d < osCount - 1; d++)
            //    {
            //        ds.Tables[0].DefaultView.RowFilter = "parentId = '" + 4 + "'";
            //        if (ds.Tables[0].DefaultView.Count > 0)
            //        {
            //            while (o3 < osCount - 1)
            //            {
            //                pageId4 = Convert.ToInt32(ds.Tables[0].DefaultView[o3]["pageId"].ToString());
            //                o3 += 1;
            //                break;
            //            }
            //        }
            //        ds.Tables[0].DefaultView.RowFilter = " ";
            //        dsExistingRights.Tables[0].DefaultView.RowFilter = "pageId = '" + pageId4 + "'";
            //        if (dsExistingRights.Tables[0].DefaultView.Count > 0)
            //        {
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["addPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox orgSettingCb1 = new CheckBox();
            //                orgSettingCb1 = (CheckBox)ShftManage.Rows[d].FindControl("chbOS" + d + "1");
            //                orgSettingCb1.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox orgSettingCb1 = new CheckBox();
            //                orgSettingCb1 = (CheckBox)ShftManage.Rows[d].FindControl("chbOS" + d + "1");
            //                orgSettingCb1.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["viewPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox orgSettingCb2 = new CheckBox();
            //                orgSettingCb2 = (CheckBox)ShftManage.Rows[d].FindControl("chbOS" + d + "2");
            //                orgSettingCb2.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox orgSettingCb2 = new CheckBox();
            //                orgSettingCb2 = (CheckBox)ShftManage.Rows[d].FindControl("chbOS" + d + "2");
            //                orgSettingCb2.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["modifyPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox orgSettingCb3 = new CheckBox();
            //                orgSettingCb3 = (CheckBox)ShftManage.Rows[d].FindControl("chbOS" + d + "3");
            //                orgSettingCb3.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox orgSettingCb3 = new CheckBox();
            //                orgSettingCb3 = (CheckBox)ShftManage.Rows[d].FindControl("chbOS" + d + "3");
            //                orgSettingCb3.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["deletePrv"].ToString().Contains("True")))
            //            {
            //                CheckBox orgSettingCb4 = new CheckBox();
            //                orgSettingCb4 = (CheckBox)ShftManage.Rows[d].FindControl("chbOS" + d + "4");
            //                orgSettingCb4.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox orgSettingCb4 = new CheckBox();
            //                orgSettingCb4 = (CheckBox)ShftManage.Rows[d].FindControl("chbOS" + d + "4");
            //                orgSettingCb4.Checked = false;
            //            }
            //            dsExistingRights.Tables[0].DefaultView.RowFilter = " ";
            //        }
            //        else
            //        {
            //            CheckBox orgSettingCb1 = new CheckBox();
            //            orgSettingCb1 = (CheckBox)ShftManage.Rows[d].FindControl("chbOS" + d + "1");
            //            orgSettingCb1.Checked = false;
            //            CheckBox orgSettingCb2 = new CheckBox();
            //            orgSettingCb2 = (CheckBox)ShftManage.Rows[d].FindControl("chbOS" + d + "2");
            //            orgSettingCb2.Checked = false;
            //            CheckBox orgSettingCb3 = new CheckBox();
            //            orgSettingCb3 = (CheckBox)ShftManage.Rows[d].FindControl("chbOS" + d + "3");
            //            orgSettingCb3.Checked = false;
            //            CheckBox orgSettingCb4 = new CheckBox();
            //            orgSettingCb4 = (CheckBox)ShftManage.Rows[d].FindControl("chbOS" + d + "4");
            //            orgSettingCb4.Checked = false;
            //        }
            //    }
            //    #endregion
            //    #region status from database for system setting
            //    int s3 = 0;
            //    for (e = 0; e < ssCouont - 1; e++)
            //    {
            //        ds.Tables[0].DefaultView.RowFilter = "parentId = '" + 5 + "'";
            //        if (ds.Tables[0].DefaultView.Count > 0)
            //        {
            //            while (s3 < ssCouont - 1)
            //            {
            //                pageId5 = Convert.ToInt32(ds.Tables[0].DefaultView[s3]["pageId"].ToString());
            //                s3 += 1;
            //                break;
            //            }
            //        }
            //        ds.Tables[0].DefaultView.RowFilter = " ";
            //        dsExistingRights.Tables[0].DefaultView.RowFilter = "pageId = '" + pageId5 + "'";
            //        if (dsExistingRights.Tables[0].DefaultView.Count > 0)
            //        {
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["addPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox sysSettingCb1 = new CheckBox();
            //                sysSettingCb1 = (CheckBox)sysSetting.Rows[e].FindControl("chbSS" + e + "1");
            //                sysSettingCb1.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox sysSettingCb1 = new CheckBox();
            //                sysSettingCb1 = (CheckBox)sysSetting.Rows[e].FindControl("chbSS" + e + "1");
            //                sysSettingCb1.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["viewPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox sysSettingCb2 = new CheckBox();
            //                sysSettingCb2 = (CheckBox)sysSetting.Rows[e].FindControl("chbSS" + e + "2");
            //                sysSettingCb2.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox sysSettingCb2 = new CheckBox();
            //                sysSettingCb2 = (CheckBox)sysSetting.Rows[e].FindControl("chbSS" + e + "2");
            //                sysSettingCb2.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["modifyPrv"].ToString().Contains("True")))
            //            {
            //                CheckBox sysSettingCb3 = new CheckBox();
            //                sysSettingCb3 = (CheckBox)sysSetting.Rows[e].FindControl("chbSS" + e + "3");
            //                sysSettingCb3.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox sysSettingCb3 = new CheckBox();
            //                sysSettingCb3 = (CheckBox)sysSetting.Rows[e].FindControl("chbSS" + e + "3");
            //                sysSettingCb3.Checked = false;
            //            }
            //            if ((dsExistingRights.Tables[0].DefaultView[0]["deletePrv"].ToString().Contains("True")))
            //            {
            //                CheckBox sysSettingCb4 = new CheckBox();
            //                sysSettingCb4 = (CheckBox)sysSetting.Rows[e].FindControl("chbSS" + e + "4");
            //                sysSettingCb4.Checked = true;
            //            }
            //            else
            //            {
            //                CheckBox sysSettingCb4 = new CheckBox();
            //                sysSettingCb4 = (CheckBox)sysSetting.Rows[e].FindControl("chbSS" + e + "4");
            //                sysSettingCb4.Checked = false;
            //            }
            //            dsExistingRights.Tables[0].DefaultView.RowFilter = " ";
            //        }
            //        else
            //        {
            //            CheckBox sysSettingCb1 = new CheckBox();
            //            sysSettingCb1 = (CheckBox)sysSetting.Rows[e].FindControl("chbSS" + e + "1");
            //            sysSettingCb1.Checked = false;
            //            CheckBox sysSettingCb2 = new CheckBox();
            //            sysSettingCb2 = (CheckBox)sysSetting.Rows[e].FindControl("chbSS" + e + "2");
            //            sysSettingCb2.Checked = false;
            //            CheckBox sysSettingCb3 = new CheckBox();
            //            sysSettingCb3 = (CheckBox)sysSetting.Rows[e].FindControl("chbSS" + e + "3");
            //            sysSettingCb3.Checked = false;
            //            CheckBox sysSettingCb4 = new CheckBox();
            //            sysSettingCb4 = (CheckBox)sysSetting.Rows[e].FindControl("chbSS" + e + "4");
            //            sysSettingCb4.Checked = false;
            //        }
            //    }
            //    #endregion
        }
    }
    //Getting Information from resource file and display it in label
    private void LoadStrings(CultureInfo ci)
    {
        lbl_HeaderUserGroups.Text = rm.GetString("Menu_Masters_UserGroups", ci);
        lbl_UserGroup.Text = rm.GetString("UserGroups_UserGroupName", ci) + " :";
        lbl_Program.Text = rm.GetString("UserGroups_Program", ci);
        btn_save.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Save", ci);
        btn_cancel.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Back", ci);
        //chkAllAddM.Text = rm.GetString("btn_Add", ci);
        //chkAllViewM.Text = rm.GetString("btn_View", ci);
        //chkAllModifyM.Text = rm.GetString("btn_Modify", ci);
        //chkAllDeleteM.Text = rm.GetString("btn_Delete", ci);
        DDL_Program.Items[0].Text = rm.GetString("Menu_Masters", ci);
        DDL_Program.Items[1].Text = rm.GetString("Menu_Transactions", ci);
        DDL_Program.Items[2].Text = rm.GetString("Menu_Reports", ci);
        DDL_Program.Items[3].Text = rm.GetString("Menu_Org_Settings", ci);
        DDL_Program.Items[4].Text = rm.GetString("Menu_System_Settings", ci);
        lblLoading.Text = rm.GetString("ProgressBarText", ci);
        lblModuleRights.Text = rm.GetString("ModuleRights", ci);

    }

    /// <summary>
    /// controls are dynamically generated here
    /// </summary>
    private void generateControls()
    {
        //get the culture info to set the language
        CultureInfo ci;
        if (Session["Session_ActiveLanguage"] == null)
        {
            Response.Redirect("../index.aspx");
        }
        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        #region dynamic control creation using default view, rowfilter
        // dynemic generation for EmpManage division
        #region Menu_Configuration

        ds.Tables[0].DefaultView.RowFilter = "";
        for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
        {
            #region Header
            DataSet dsChildMenu = new DataSet();
            int pageid = 0;
            pageid = Convert.ToInt32(ds.Tables[0].Rows[j][0]);
            dsChildMenu = objUserRight.GetChildMenus(Convert.ToInt32(ds.Tables[0].Rows[j][0]));
            int rowcount = 0;
            rowcount = dsChildMenu.Tables[0].Rows.Count;
            rowcount = (rowcount == 0) ? 1 : rowcount;

            int K = 0;
            Table tbl = new Table();
            tbl.CssClass = "table table-bordered user-table";
            tbl.Style.Add("margin", "10px");
            tbl.Style.Add("border", "1px solid #c5dffc");
            tbl.Style.Add("width", "95%");
            tbl.ID = "MenuTable" + j;
            TableHeaderRow trow = new TableHeaderRow();

            TableCell tcHeaderModule = new TableCell();
            tcHeader.CssClass = "table-her";
            Label lblHeaderModule = new Label();
            lblHeaderModule.ID = "tcHeaderModule" + j;
            lblHeaderModule.Text = rm.GetString(Convert.ToString(ds.Tables[0].Rows[j][1]), ci);
            tcHeaderModule.Style.Add("text-align", "center");
            tcHeaderModule.CssClass = "col-md-4  table-her minwithUser";
            tcHeaderModule.Style.Add("width", "30%");
            tcHeaderModule.Controls.Add(lblHeaderModule);
            trow.Cells.Add(tcHeaderModule);

            TableCell tcHeaderaddModule = new TableCell();
            CheckBox chbHeaderadd = new CheckBox();
            chbHeaderadd.ID = "chbHeaderadd" + j;
            //chbHeaderadd.CssClass = "checkboxLeave checkboxLeave-primary";
            chbHeaderadd.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Add", ci);
            chbHeaderadd.Attributes.Add("onClick", "CheckAdd(this," + rowcount + "," + Convert.ToInt16(j) + ");");
            tcHeaderaddModule.CssClass = "col-md-2 table-her";
            tcHeaderaddModule.Style.Add("width", "15%");
            tcHeaderaddModule.Style.Add("text-align", "center");
            tcHeaderaddModule.Controls.Add(chbHeaderadd);
            trow.Cells.Add(tcHeaderaddModule);

            TableCell tcHeaderViewModule = new TableCell();
            tcHeaderViewModule.CssClass = "table-her";
            CheckBox chbHeaderView = new CheckBox();
            chbHeaderView.ID = "chbHeaderView" + j;
            chbHeaderView.Text = "&nbsp;&nbsp;" + rm.GetString("btn_View", ci);
            //chbHeaderView.CssClass = "checkboxLeave checkboxLeave-primary";
            chbHeaderView.Attributes.Add("onClick", "CheckView(this," + rowcount + "," + Convert.ToInt16(j) + ");");
            tcHeaderViewModule.CssClass = "col-md-2 table-her";
            tcHeaderViewModule.Style.Add("width", "15%");
            tcHeaderViewModule.Style.Add("text-align", "center");
            tcHeaderViewModule.Controls.Add(chbHeaderView);
            trow.Cells.Add(tcHeaderViewModule);

            TableCell tcHeaderModifyModule = new TableCell();
            CheckBox chbHeaderModify = new CheckBox();
            chbHeaderModify.ID = "chbHeaderModify" + j;
            chbHeaderModify.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Modify", ci);
            //chbHeaderModify.CssClass = "checkboxLeave checkboxLeave-primary";
            chbHeaderModify.Attributes.Add("onClick", "CheckModify(this," + rowcount + "," + Convert.ToInt16(j) + ");");
            tcHeaderModifyModule.CssClass = "col-md-2 table-her";
            tcHeaderModifyModule.Style.Add("width", "15%");
            tcHeaderModifyModule.Style.Add("text-align", "center");
            tcHeaderModifyModule.Controls.Add(chbHeaderModify);
            trow.Cells.Add(tcHeaderModifyModule);

            TableCell tcHeaderDeleteModule = new TableCell();
            CheckBox chbHeaderDelete = new CheckBox();
            chbHeaderDelete.ID = "chbHeaderDelete" + j;
            chbHeaderDelete.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Delete", ci);
            //chbHeaderDelete.CssClass = "checkboxLeave checkboxLeave-primary";
            chbHeaderDelete.Attributes.Add("onClick", "CheckDelete(this," + rowcount + "," + Convert.ToInt16(j) + ");");
            tcHeaderDeleteModule.CssClass = "col-md-2 table-her";
            tcHeaderDeleteModule.Style.Add("width", "15%");
            tcHeaderDeleteModule.Style.Add("text-align", "center");
            tcHeaderDeleteModule.Controls.Add(chbHeaderDelete);
            trow.Cells.Add(tcHeaderDeleteModule);

            TableCell tcHeaderPageID = new TableCell();
            tcHeaderPageID.Style.Add("display", "none");
            Label HeaderPageid = new Label();
            HeaderPageid.ID = "lblHeaderPageid" + j;
            HeaderPageid.Text = Convert.ToString(ds.Tables[0].Rows[j][0]);
            tcHeaderPageID.Controls.Add(HeaderPageid);
            trow.Cells.Add(tcHeaderPageID);


            TableCell tcHeaderPagegroupID = new TableCell();
            Label HeaderPagegroupid = new Label();
            tcHeaderPagegroupID.Style.Add("display", "none");
            HeaderPagegroupid.ID = "lblHeaderPagegroupid" + j;
            HeaderPagegroupid.Text = Convert.ToString(ds.Tables[0].Rows[j][3]);
            tcHeaderPagegroupID.Controls.Add(HeaderPagegroupid);
            trow.Cells.Add(tcHeaderPagegroupID);

            tbl.Controls.Add(trow);
            #endregion
            int i = 0;
            int ReportsMenu = 0;
            if (dsChildMenu.Tables.Count > 0)
            {
                if (dsChildMenu.Tables[0].Rows.Count == 0)
                {
                    #region ChildMenu

                    TableRow trconfig = new TableRow();
                    TableCell tcconfig = new TableCell();
                    Label lblconfig1 = new Label();
                    lblconfig1.ID = "lblconfigModuleName" + j + K;

                    string str = rm.GetString(Convert.ToString(ds.Tables[0].Rows[j][1]), ci);
                    lblconfig1.Text = str;
                    tcconfig.CssClass = "col-md-4";
                    tcconfig.Style.Add("width", "30%");
                    tcconfig.Controls.Add(lblconfig1);
                    trconfig.Cells.Add(tcconfig);
                    TableCell tcconfig2 = new TableCell();
                    CheckBox chbconfig1 = new CheckBox();
                    //if (Convert.ToString(ds.Tables[0].Rows[j][0]) == "179")
                    //{
                    //    chbconfig1.Enabled = false;
                    //}
                    chbconfig1.ID = "chbconfigAdd" + j + K;
                    //chbconfig1.CssClass = "checkboxLeave checkboxLeave-primary";
                    chbconfig1.Text = " ";
                    tcconfig2.CssClass = "col-md-2";
                    tcconfig2.Style.Add("width", "15%");
                    tcconfig2.Style.Add("text-align", "center");
                    tcconfig2.Controls.Add(chbconfig1);
                    trconfig.Cells.Add(tcconfig2);
                    TableCell tcconfig3 = new TableCell();
                    CheckBox chbconfig2 = new CheckBox();
                    chbconfig2.Text = " ";
                    //if (Convert.ToString(ds.Tables[0].Rows[j][0]) == "179")
                    //{
                    //    chbconfig2.Enabled = false;
                    //}
                    //chbconfig2.CssClass = "checkboxLeave checkboxLeave-primary";
                    chbconfig2.ID = "chbconfigView" + j + K;
                    tcconfig3.CssClass = "col-md-2";
                    tcconfig3.Style.Add("width", "15%");
                    tcconfig3.Style.Add("text-align", "center");
                    tcconfig3.Controls.Add(chbconfig2);
                    trconfig.Cells.Add(tcconfig3);
                    TableCell tcconfig4 = new TableCell();
                    CheckBox chbconfig3 = new CheckBox();
                    chbconfig3.ID = "chbconfigModify" + j + K;
                    //if (Convert.ToString(ds.Tables[0].Rows[j][0]) == "179")
                    //{
                    //    chbconfig3.Enabled = false;
                    //}
                    chbconfig3.Text = " ";
                    //chbconfig3.CssClass = "checkboxLeave checkboxLeave-primary";
                    tcconfig4.CssClass = "col-md-2";
                    tcconfig4.Style.Add("width", "15%");
                    tcconfig4.Style.Add("text-align", "center");
                    tcconfig4.Controls.Add(chbconfig3);
                    trconfig.Cells.Add(tcconfig4);
                    TableCell tcconfig5 = new TableCell();
                    CheckBox chbconfig4 = new CheckBox();
                    //if (Convert.ToString(ds.Tables[0].Rows[j][0]) == "179")
                    //{
                    //    chbconfig4.Enabled = false;
                    //}
                    chbconfig4.Text = " ";
                    chbconfig4.ID = "chbconfigDelete" + j + K;
                    //chbconfig4.CssClass = "checkboxLeave checkboxLeave-primary";
                    tcconfig5.CssClass = "col-md-2";
                    tcconfig5.Style.Add("width", "15%");
                    tcconfig5.Style.Add("text-align", "center");
                    tcconfig5.Controls.Add(chbconfig4);
                    trconfig.Cells.Add(tcconfig5);

                    TableCell tcconfig6 = new TableCell();
                    Label lblPageid = new Label();
                    tcconfig6.Style.Add("display", "none");
                    lblPageid.ID = "lblPageid" + j + K;
                    lblPageid.Text = Convert.ToString(ds.Tables[0].Rows[j][0]);
                    tcconfig6.Controls.Add(lblPageid);
                    trconfig.Cells.Add(tcconfig6);

                    TableCell tcconfig7 = new TableCell();
                    tcconfig7.Style.Add("display", "none");
                    Label lblPagegroupid = new Label();
                    lblPagegroupid.ID = "lblPagegroupid" + j + K;
                    lblPagegroupid.Text = Convert.ToString(ds.Tables[0].Rows[j][3]);
                    tcconfig7.Controls.Add(lblPagegroupid);
                    trconfig.Cells.Add(tcconfig7);

                    tbl.Rows.Add(trconfig);
                    #endregion
                }
            }
            foreach (DataRow rowConfig in dsChildMenu.Tables[0].Rows)
            {
                #region ChildMenu
                ReportsMenu = Convert.ToInt16(dsChildMenu.Tables[0].DefaultView[i]["ReportMenus"]);

                TableRow trconfig = new TableRow();
                TableCell tcconfig = new TableCell();
                Label lblconfig1 = new Label();
                lblconfig1.ID = "lblconfigModuleName" + j + K;

                string str = dsChildMenu.Tables[0].DefaultView[i]["displayName"].ToString();
                lblconfig1.Text = rm.GetString(str, ci);
                tcconfig.CssClass = "col-md-4";
                tcconfig.Style.Add("width", "30%");
                tcconfig.Controls.Add(lblconfig1);
                trconfig.Cells.Add(tcconfig);
                TableCell tcconfig2 = new TableCell();
                CheckBox chbconfig1 = new CheckBox();
                chbconfig1.ID = "chbconfigAdd" + j + K;
                //chbconfig1.CssClass = "checkboxLeave checkboxLeave-primary";
                chbconfig1.Text = " ";
                if (ReportsMenu == 1 && (Convert.ToString(dsChildMenu.Tables[0].DefaultView[i]["pageid"]) != "103" && Convert.ToString(dsChildMenu.Tables[0].DefaultView[i]["pageid"]) != "116"))
                    chbconfig1.Enabled = false;

                tcconfig2.CssClass = "col-md-2";
                tcconfig2.Style.Add("width", "15%");
                tcconfig2.Style.Add("text-align", "center");
                tcconfig2.Controls.Add(chbconfig1);
                trconfig.Cells.Add(tcconfig2);
                TableCell tcconfig3 = new TableCell();
                CheckBox chbconfig2 = new CheckBox();
                chbconfig2.Text = " ";
                //chbconfig2.CssClass = "checkboxLeave checkboxLeave-primary";
                if (ReportsMenu == 1 && (Convert.ToString(dsChildMenu.Tables[0].DefaultView[i]["pageid"]) == "103") || Convert.ToString(dsChildMenu.Tables[0].DefaultView[i]["pageid"]) == "116")
                    chbconfig2.Enabled = false;

                chbconfig2.ID = "chbconfigView" + j + K;
                tcconfig3.CssClass = "col-md-2";
                tcconfig3.Style.Add("width", "15%");
                tcconfig3.Style.Add("text-align", "center");
                tcconfig3.Controls.Add(chbconfig2);
                trconfig.Cells.Add(tcconfig3);
                TableCell tcconfig4 = new TableCell();
                CheckBox chbconfig3 = new CheckBox();
                chbconfig3.ID = "chbconfigModify" + j + K;
                chbconfig3.Text = " ";
                if (ReportsMenu == 1)
                    chbconfig3.Enabled = false;
                //chbconfig3.CssClass = "checkboxLeave checkboxLeave-primary";
                tcconfig4.CssClass = "col-md-2";
                tcconfig4.Style.Add("width", "15%");
                tcconfig4.Style.Add("text-align", "center");
                tcconfig4.Controls.Add(chbconfig3);
                trconfig.Cells.Add(tcconfig4);
                TableCell tcconfig5 = new TableCell();
                CheckBox chbconfig4 = new CheckBox();
                chbconfig4.Text = " ";
                chbconfig4.ID = "chbconfigDelete" + j + K;
                if (ReportsMenu == 1)
                    chbconfig4.Enabled = false;
                //chbconfig4.CssClass = "checkboxLeave checkboxLeave-primary";
                tcconfig5.CssClass = "col-md-2";
                tcconfig5.Style.Add("width", "15%");
                tcconfig5.Style.Add("text-align", "center");
                tcconfig5.Controls.Add(chbconfig4);
                trconfig.Cells.Add(tcconfig5);

                TableCell tcconfig6 = new TableCell();
                Label lblPageid = new Label();
                tcconfig6.Style.Add("display", "none");
                lblPageid.ID = "lblPageid" + j + K;
                lblPageid.Text = Convert.ToString(dsChildMenu.Tables[0].DefaultView[i]["pageid"]);
                tcconfig6.Controls.Add(lblPageid);
                trconfig.Cells.Add(tcconfig6);

                TableCell tcconfig7 = new TableCell();
                tcconfig7.Style.Add("display", "none");
                Label lblPagegroupid = new Label();
                lblPagegroupid.ID = "lblPagegroupid" + j + K;
                lblPagegroupid.Text = Convert.ToString(dsChildMenu.Tables[0].DefaultView[i]["parentid"]);
                tcconfig7.Controls.Add(lblPagegroupid);
                trconfig.Cells.Add(tcconfig7);

                tbl.Rows.Add(trconfig);
                K += 1;
                i += 1;
                #endregion
            }
            Panel1.Controls.Add(tbl);
        }
        #endregion
        shouldCreateControl = true;
        #endregion
    }
    #endregion
    #region CheckboxEvents
    protected void chkAllAddM_CheckedChanged(object sender, EventArgs e)
    {
        //set check and check all for respective modules
        //int masterCount;
        //masterCount = EmpManage.Rows.Count;
        //int i = 0;
        //if (chkAllAddM.Checked)
        //{
        //    for (i = 0; i < masterCount - 1; i++)
        //    {
        //        CheckBox masterCb1 = new CheckBox();
        //        masterCb1 = (CheckBox)EmpManage.Rows[i].FindControl("chbEmpManage" + i + "1");
        //        masterCb1.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (i = 0; i < masterCount - 1; i++)
        //    {
        //        CheckBox masterCb1 = new CheckBox();
        //        masterCb1 = (CheckBox)EmpManage.Rows[i].FindControl("chbEmpManage" + i + "1");
        //        masterCb1.Checked = false;
        //        Label lblUserGroups = new Label();
        //        lblUserGroups = (Label)EmpManage.Rows[i].FindControl("lblMasterUserGroupsPageId" + i);
        //        if (lblGroupName.Text == "SuperAdmin" && lblUserGroups.Text == "21")
        //        {
        //            masterCb1.Checked = true;
        //        }
        //    }
        //}
    }
    protected void chkAllViewM_CheckedChanged(object sender, EventArgs e)
    {
        //set check and check all for respective modules
        //int masterCount;
        //masterCount = EmpManage.Rows.Count;
        //int i = 0;
        //if (chkAllViewM.Checked)
        //{
        //    for (i = 0; i < masterCount - 1; i++)
        //    {
        //        CheckBox masterCb2 = new CheckBox();
        //        masterCb2 = (CheckBox)EmpManage.Rows[i].FindControl("chbEmpManage" + i + "2");
        //        masterCb2.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (i = 0; i < masterCount - 1; i++)
        //    {
        //        CheckBox masterCb2 = new CheckBox();
        //        masterCb2 = (CheckBox)EmpManage.Rows[i].FindControl("chbEmpManage" + i + "2");
        //        masterCb2.Checked = false;
        //        Label lblUserGroups = new Label();
        //        lblUserGroups = (Label)EmpManage.Rows[i].FindControl("lblMasterUserGroupsPageId" + i);
        //        if (lblGroupName.Text == "SuperAdmin" && lblUserGroups.Text == "21")
        //        {
        //            masterCb2.Checked = true;
        //        }
        //    }
        //}
    }
    protected void chkAllModifyM_CheckedChanged(object sender, EventArgs e)
    {
        ////set check and check all for respective modules
        //int masterCount;
        //masterCount = EmpManage.Rows.Count;
        //int i = 0;
        //if (chkAllModifyM.Checked)
        //{
        //    for (i = 0; i < masterCount - 1; i++)
        //    {
        //        CheckBox masterCb3 = new CheckBox();
        //        masterCb3 = (CheckBox)EmpManage.Rows[i].FindControl("chbEmpManage" + i + "3");
        //        masterCb3.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (i = 0; i < masterCount - 1; i++)
        //    {
        //        CheckBox masterCb3 = new CheckBox();
        //        masterCb3 = (CheckBox)EmpManage.Rows[i].FindControl("chbEmpManage" + i + "3");
        //        masterCb3.Checked = false;
        //        Label lblUserGroups = new Label();
        //        lblUserGroups = (Label)EmpManage.Rows[i].FindControl("lblMasterUserGroupsPageId" + i);
        //        if (lblGroupName.Text == "SuperAdmin" && lblUserGroups.Text == "21")
        //        {
        //            masterCb3.Checked = true;
        //        }
        //    }
        //}
    }
    protected void chkAllDeleteM_CheckedChanged(object sender, EventArgs e)
    {
        ////set check and check all for respective modules
        //int masterCount;
        //masterCount = EmpManage.Rows.Count;
        //int i = 0;
        //if (chkAllDeleteM.Checked)
        //{
        //    for (i = 0; i < masterCount - 1; i++)
        //    {
        //        CheckBox masterCb4 = new CheckBox();
        //        masterCb4 = (CheckBox)EmpManage.Rows[i].FindControl("chbEmpManage" + i + "4");
        //        masterCb4.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (i = 0; i < masterCount - 1; i++)
        //    {
        //        CheckBox masterCb4 = new CheckBox();
        //        masterCb4 = (CheckBox)EmpManage.Rows[i].FindControl("chbEmpManage" + i + "4");
        //        masterCb4.Checked = false;
        //        Label lblUserGroups = new Label();
        //        lblUserGroups = (Label)EmpManage.Rows[i].FindControl("lblMasterUserGroupsPageId" + i);
        //        if (lblGroupName.Text == "SuperAdmin" && lblUserGroups.Text == "21")
        //        {
        //            masterCb4.Checked = true;
        //        }
        //    }
        //}
    }
    protected void chkAllAddT_CheckedChanged(object sender, EventArgs e)
    {
        //set check and check all for respective modules
        //int transactionCount;
        //transactionCount = devManage.Rows.Count;
        //int j = 0;
        //if (chkAllAddT.Checked)
        //{
        //    for (j = 0; j < transactionCount - 1; j++)
        //    {
        //        CheckBox tranCb1 = new CheckBox();
        //        tranCb1 = (CheckBox)devManage.Rows[j].FindControl("chbdevManage" + j + "1");
        //        tranCb1.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (j = 0; j < transactionCount - 1; j++)
        //    {
        //        CheckBox tranCb1 = new CheckBox();
        //        tranCb1 = (CheckBox)devManage.Rows[j].FindControl("chbdevManage" + j + "1");
        //        tranCb1.Checked = false;
        //    }
        //}
    }
    protected void chkAllViewT_CheckedChanged(object sender, EventArgs e)
    {
        ////set check and check all for respective modules
        //int transactionCount;
        //transactionCount = devManage.Rows.Count;
        //int j = 0;
        //if (chkAllViewT.Checked)
        //{
        //    for (j = 0; j < transactionCount - 1; j++)
        //    {
        //        CheckBox tranCb2 = new CheckBox();
        //        tranCb2 = (CheckBox)devManage.Rows[j].FindControl("chbdevManage" + j + "2");
        //        tranCb2.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (j = 0; j < transactionCount - 1; j++)
        //    {
        //        CheckBox tranCb2 = new CheckBox();
        //        tranCb2 = (CheckBox)devManage.Rows[j].FindControl("chbdevManage" + j + "2");
        //        tranCb2.Checked = false;
        //    }
        //}
    }
    protected void chkAllModifyT_CheckedChanged(object sender, EventArgs e)
    {
        ////set check and check all for respective modules
        //int transactionCount;
        //transactionCount = devManage.Rows.Count;
        //int j = 0;
        //if (chkAllModifyT.Checked)
        //{
        //    for (j = 0; j < transactionCount - 1; j++)
        //    {
        //        CheckBox tranCb3 = new CheckBox();
        //        tranCb3 = (CheckBox)devManage.Rows[j].FindControl("chbdevManage" + j + "3");
        //        tranCb3.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (j = 0; j < transactionCount - 1; j++)
        //    {
        //        CheckBox tranCb3 = new CheckBox();
        //        tranCb3 = (CheckBox)devManage.Rows[j].FindControl("chbdevManage" + j + "3");
        //        tranCb3.Checked = false;
        //    }
        //}
    }
    protected void chkAllDeleteT_CheckedChanged(object sender, EventArgs e)
    {
        //set check and check all for respective modules
        //int transactionCount;
        //transactionCount = devManage.Rows.Count;
        //int j = 0;
        //if (chkAllDeleteT.Checked)
        //{
        //    for (j = 0; j < transactionCount - 1; j++)
        //    {
        //        CheckBox tranCb4 = new CheckBox();
        //        tranCb4 = (CheckBox)devManage.Rows[j].FindControl("chbdevManage" + j + "4");
        //        tranCb4.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (j = 0; j < transactionCount - 1; j++)
        //    {
        //        CheckBox tranCb4 = new CheckBox();
        //        tranCb4 = (CheckBox)devManage.Rows[j].FindControl("chbdevManage" + j + "4");
        //        tranCb4.Checked = false;
        //    }
        //}
    }
    protected void chkAllAddR_CheckedChanged(object sender, EventArgs e)
    {
        //set check and check all for respective modules
        //int reportCount;
        //reportCount = report.Rows.Count;
        //int k = 0;
        //if (chkAllAddR.Checked)
        //{
        //    for (k = 0; k < reportCount - 1; k++)
        //    {
        //        CheckBox reportCb1 = new CheckBox();
        //        reportCb1 = (CheckBox)report.Rows[k].FindControl("chbReport" + k + "1");
        //        reportCb1.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (k = 0; k < reportCount - 1; k++)
        //    {
        //        CheckBox reportCb1 = new CheckBox();
        //        reportCb1 = (CheckBox)report.Rows[k].FindControl("chbReport" + k + "1");
        //        reportCb1.Checked = false;
        //    }
        //}
    }
    protected void chkAllViewR_CheckedChanged(object sender, EventArgs e)
    {
        ////set check and check all for respective modules
        //int reportCount;
        //reportCount = report.Rows.Count;
        //int k = 0;
        //if (chkAllViewR.Checked)
        //{
        //    for (k = 0; k < reportCount - 1; k++)
        //    {
        //        CheckBox reportCb2 = new CheckBox();
        //        reportCb2 = (CheckBox)report.Rows[k].FindControl("chbReport" + k + "2");
        //        reportCb2.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (k = 0; k < reportCount - 1; k++)
        //    {
        //        CheckBox reportCb2 = new CheckBox();
        //        reportCb2 = (CheckBox)report.Rows[k].FindControl("chbReport" + k + "2");
        //        reportCb2.Checked = false;
        //    }
        //}
    }
    protected void chkAllModifyR_CheckedChanged(object sender, EventArgs e)
    {
        ////set check and check all for respective modules
        //int reportCount;
        //reportCount = report.Rows.Count;
        //int k = 0;
        //if (chkAllModifyR.Checked)
        //{
        //    for (k = 0; k < reportCount - 1; k++)
        //    {
        //        CheckBox reportCb3 = new CheckBox();
        //        reportCb3 = (CheckBox)report.Rows[k].FindControl("chbReport" + k + "3");
        //        reportCb3.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (k = 0; k < reportCount - 1; k++)
        //    {
        //        CheckBox reportCb3 = new CheckBox();
        //        reportCb3 = (CheckBox)report.Rows[k].FindControl("chbReport" + k + "3");
        //        reportCb3.Checked = false;
        //    }
        //}
    }
    protected void chkAllDeleteR_CheckedChanged(object sender, EventArgs e)
    {
        ////set check and check all for respective modules
        //int reportCount;
        //reportCount = report.Rows.Count;
        //int k = 0;
        //if (chkAllDeleteR.Checked)
        //{
        //    for (k = 0; k < reportCount - 1; k++)
        //    {
        //        CheckBox reportCb4 = new CheckBox();
        //        reportCb4 = (CheckBox)report.Rows[k].FindControl("chbReport" + k + "4");
        //        reportCb4.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (k = 0; k < reportCount - 1; k++)
        //    {
        //        CheckBox reportCb4 = new CheckBox();
        //        reportCb4 = (CheckBox)report.Rows[k].FindControl("chbReport" + k + "4");
        //        reportCb4.Checked = false;
        //    }
        //}
    }
    protected void chkAllAddOS_CheckedChanged(object sender, EventArgs e)
    {
        ////set check and check all for respective modules
        //int osCount;
        //osCount = ShftManage.Rows.Count;
        //int l = 0;
        //if (chkAllAddOS.Checked)
        //{
        //    for (l = 0; l < osCount - 1; l++)
        //    {
        //        CheckBox osCb1 = new CheckBox();
        //        osCb1 = (CheckBox)ShftManage.Rows[l].FindControl("chbOS" + l + "1");
        //        osCb1.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (l = 0; l < osCount - 1; l++)
        //    {
        //        CheckBox osCb1 = new CheckBox();
        //        osCb1 = (CheckBox)ShftManage.Rows[l].FindControl("chbOS" + l + "1");
        //        osCb1.Checked = false;
        //    }
        //}
    }
    protected void chkAllViewOS_CheckedChanged(object sender, EventArgs e)
    {
        ////set check and check all for respective modules
        //int osCount;
        //osCount = ShftManage.Rows.Count;
        //int l = 0;
        //if (chkAllViewOS.Checked)
        //{
        //    for (l = 0; l < osCount - 1; l++)
        //    {
        //        CheckBox osCb2 = new CheckBox();
        //        osCb2 = (CheckBox)ShftManage.Rows[l].FindControl("chbOS" + l + "2");
        //        osCb2.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (l = 0; l < osCount - 1; l++)
        //    {
        //        CheckBox osCb2 = new CheckBox();
        //        osCb2 = (CheckBox)ShftManage.Rows[l].FindControl("chbOS" + l + "2");
        //        osCb2.Checked = false;
        //    }
        //}
    }
    protected void chkAllModifyOS_CheckedChanged(object sender, EventArgs e)
    {
        //set check and check all for respective modules
        //int osCount;
        //osCount = ShftManage.Rows.Count;
        //int l = 0;
        //if (chkAllModifyOS.Checked)
        //{
        //    for (l = 0; l < osCount - 1; l++)
        //    {
        //        CheckBox osCb3 = new CheckBox();
        //        osCb3 = (CheckBox)ShftManage.Rows[l].FindControl("chbOS" + l + "3");
        //        osCb3.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (l = 0; l < osCount - 1; l++)
        //    {
        //        CheckBox osCb3 = new CheckBox();
        //        osCb3 = (CheckBox)ShftManage.Rows[l].FindControl("chbOS" + l + "3");
        //        osCb3.Checked = false;
        //    }
        //}
    }
    protected void chkAllDeleteOS_CheckedChanged(object sender, EventArgs e)
    {
        //set check and check all for respective modules
        //int osCount;
        //osCount = ShftManage.Rows.Count;
        //int l = 0;
        //if (chkAllDeleteOS.Checked)
        //{
        //    for (l = 0; l < osCount - 1; l++)
        //    {
        //        CheckBox osCb4 = new CheckBox();
        //        osCb4 = (CheckBox)ShftManage.Rows[l].FindControl("chbOS" + l + "4");
        //        osCb4.Checked = true;
        //    }
        //}
        //else
        //{
        //    for (l = 0; l < osCount - 1; l++)
        //    {
        //        CheckBox osCb4 = new CheckBox();
        //        osCb4 = (CheckBox)ShftManage.Rows[l].FindControl("chbOS" + l + "4");
        //        osCb4.Checked = false;
        //    }
        //}
    }
    protected void chkAllAddSS_CheckedChanged(object sender, EventArgs e)
    {
        //set check and check all for respective modules
        //int ssCouont;
        //ssCouont = sysSetting.Rows.Count;
        //int m = 0;
        //if (chkAllAddSS.Checked)
        //{
        //    for (m = 0; m < ssCouont - 1; m++)
        //    {
        //        CheckBox ssCb1 = new CheckBox();
        //        ssCb1 = (CheckBox)sysSetting.Rows[m].FindControl("chbSS" + m + "1");
        //        if (ssCb1.Enabled == true)
        //        {
        //            ssCb1.Checked = true;
        //        }
        //    }
        //}
        //else
        //{
        //    for (m = 0; m < ssCouont - 1; m++)
        //    {
        //        CheckBox ssCb1 = new CheckBox();
        //        ssCb1 = (CheckBox)sysSetting.Rows[m].FindControl("chbSS" + m + "1");
        //        ssCb1.Checked = false;
        //    }
        //}
    }
    protected void chkAllViewSS_CheckedChanged(object sender, EventArgs e)
    {
        //set check and check all for respective modules
        //int ssCouont;
        //ssCouont = sysSetting.Rows.Count;
        //int m = 0;
        //if (chkAllViewSS.Checked)
        //{
        //    for (m = 0; m < ssCouont - 1; m++)
        //    {
        //        CheckBox ssCb2 = new CheckBox();
        //        ssCb2 = (CheckBox)sysSetting.Rows[m].FindControl("chbSS" + m + "2");
        //        if (ssCb2.Enabled == true)
        //        {
        //            ssCb2.Checked = true;
        //        }
        //    }
        //}
        //else
        //{
        //    for (m = 0; m < ssCouont - 1; m++)
        //    {
        //        CheckBox ssCb2 = new CheckBox();
        //        ssCb2 = (CheckBox)sysSetting.Rows[m].FindControl("chbSS" + m + "2");
        //        ssCb2.Checked = false;
        //    }
        //}
    }
    protected void chkAllModifySS_CheckedChanged(object sender, EventArgs e)
    {
        //set check and check all for respective modules
        //int ssCouont;
        //ssCouont = sysSetting.Rows.Count;
        //int m = 0;
        //if (chkAllModifySS.Checked)
        //{
        //    for (m = 0; m < ssCouont - 1; m++)
        //    {
        //        CheckBox ssCb3 = new CheckBox();
        //        ssCb3 = (CheckBox)sysSetting.Rows[m].FindControl("chbSS" + m + "3");
        //        if (ssCb3.Enabled == true)
        //        {
        //            ssCb3.Checked = true;
        //        }
        //    }
        //}
        //else
        //{
        //    for (m = 0; m < ssCouont - 1; m++)
        //    {
        //        CheckBox ssCb3 = new CheckBox();
        //        ssCb3 = (CheckBox)sysSetting.Rows[m].FindControl("chbSS" + m + "3");
        //        ssCb3.Checked = false;
        //    }
        //}
    }
    protected void chkAllDeleteSS_CheckedChanged(object sender, EventArgs e)
    {
        //set check and check all for respective modules
        //int ssCouont;
        //ssCouont = sysSetting.Rows.Count;
        //int m = 0;
        //if (chkAllDeleteSS.Checked)
        //{
        //    for (m = 0; m < ssCouont - 1; m++)
        //    {
        //        CheckBox ssCb4 = new CheckBox();
        //        ssCb4 = (CheckBox)sysSetting.Rows[m].FindControl("chbSS" + m + "4");
        //        if (ssCb4.Enabled == true)
        //        {
        //            ssCb4.Checked = true;
        //        }
        //    }
        //}
        //else
        //{
        //    for (m = 0; m < ssCouont - 1; m++)
        //    {
        //        CheckBox ssCb4 = new CheckBox();
        //        ssCb4 = (CheckBox)sysSetting.Rows[m].FindControl("chbSS" + m + "4");
        //        ssCb4.Checked = false;
        //    }
        //}
    }
    #endregion
    #region ButtonEvents
    // cancel to go back UserGroupView page
    protected void btn_cancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("TA_UI_Master_groupView.aspx");
    }
    /// <summary>
    /// enumerate through EmpManage, devManage, report, organization setting, system setting tables
    /// check checked status and update database with required data
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn_save_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < Panel1.Controls.Count - 1; i++)
        {
            Table table = (Table)Panel1.FindControl("MenuTable" + i);
            int k = 0;
            for (int j = 0; j < table.Rows.Count; j++)
            {
                int addPrv = 0, modifyPrv = 0, deletePrv = 0, viewPrv = 0;
                int headeraddPrv = 0, headermodifyPrv = 0, headerdeletePrv = 0, headerviewPrv = 0;
                int headerPageid = 0, headerPageGroupid = 0;
                int pageId = 0, pageGroup = 0;

                CheckBox chkadd = (CheckBox)table.FindControl("chbconfigAdd" + i + k);
                if (chkadd != null)
                {
                    if (chkadd.Checked == true)
                        addPrv = 1;
                }
                CheckBox chkview = (CheckBox)table.FindControl("chbconfigView" + i + k);
                if (chkview != null)
                {
                    if (chkview.Checked == true)
                        viewPrv = 1;
                }
                CheckBox chkModify = (CheckBox)table.FindControl("chbconfigModify" + i + k);
                if (chkModify != null)
                {
                    if (chkModify.Checked == true)
                        modifyPrv = 1;
                }
                CheckBox chkDelete = (CheckBox)table.FindControl("chbconfigDelete" + i + k);
                if (chkDelete != null)
                {
                    if (chkDelete.Checked == true)
                        deletePrv = 1;
                }
                Label lblPageid = (Label)table.FindControl("lblPageid" + i + k);
                if (lblPageid != null)
                {
                    if (lblPageid.Text != "")
                    {
                        pageId = Convert.ToInt32(lblPageid.Text);
                    }
                }
                Label lblPagegroupid = (Label)table.FindControl("lblPagegroupid" + i + k);
                if (lblPagegroupid != null)
                {
                    if (lblPagegroupid.Text != "")
                    {
                        pageGroup = Convert.ToInt32(lblPagegroupid.Text);
                    }
                }
                objUserRight.insertUserRights(Convert.ToInt16(Session["gid"]), pageId, pageGroup, addPrv, modifyPrv, deletePrv, viewPrv, employeeId);
                k = k + 1;
            }
        }
        //int masterCount, transactionCount, reportCount, osCount, ssCouont;
        //masterCount = EmpManage.Rows.Count;
        //transactionCount = devManage.Rows.Count;
        //reportCount = report.Rows.Count;
        //osCount = ShftManage.Rows.Count;
        //ssCouont = sysSetting.Rows.Count;
        //int i = 0, j = 0, k = 0, l = 0, m = 0;
        //int m3 = 0;
        //for (i = 0; i < masterCount - 1; i++)
        //{
        //    int pageGroup = 1;
        //    int pageId = 0;
        //    
        //    ds.Tables[0].DefaultView.RowFilter = "parentId = '" + 189 + "'";
        //    if (ds.Tables[0].DefaultView.Count > 0)
        //    {
        //        while (m3 < masterCount - 1)
        //        {
        //            pageId = Convert.ToInt32(ds.Tables[0].DefaultView[m3]["pageId"].ToString());
        //            m3 += 1;
        //            break;
        //        }
        //    }
        //    CheckBox masterCb1 = new CheckBox();
        //    masterCb1 = (CheckBox)EmpManage.Rows[i].FindControl("chbEmpManage" + i + "1");
        //    if (masterCb1.Checked)
        //    {
        //        addPrv = 1;
        //    }
        //    CheckBox masterCb2 = new CheckBox();
        //    masterCb2 = (CheckBox)EmpManage.Rows[i].FindControl("chbEmpManage" + i + "2");
        //    if (masterCb2.Checked)
        //    {
        //        viewPrv = 1;
        //    }
        //    CheckBox masterCb3 = new CheckBox();
        //    masterCb3 = (CheckBox)EmpManage.Rows[i].FindControl("chbEmpManage" + i + "3");
        //    if (masterCb3.Checked)
        //    {
        //        modifyPrv = 1;
        //    }
        //    CheckBox masterCb4 = new CheckBox();
        //    masterCb4 = (CheckBox)EmpManage.Rows[i].FindControl("chbEmpManage" + i + "4");
        //    if (masterCb4.Checked)
        //    {
        //        deletePrv = 1;
        //    }
        //    objUserRight.insertUserRights(Convert.ToInt16(Session["gid"]), pageId, pageGroup, addPrv, modifyPrv, deletePrv, viewPrv, employeeId);
        //    ds.Tables[0].DefaultView.RowFilter = " ";
        //}
        //int t3 = 0;
        //for (j = 0; j < transactionCount - 1; j++)
        //{
        //    int pageGroup = 2;
        //    int pageId = 0;
        //    int addPrv = 0, modifyPrv = 0, deletePrv = 0, viewPrv = 0;
        //    ds.Tables[0].DefaultView.RowFilter = "parentId = '" + 187 + "'";
        //    if (ds.Tables[0].DefaultView.Count > 0)
        //    {
        //        while (t3 < transactionCount - 1)
        //        {
        //            pageId = Convert.ToInt32(ds.Tables[0].DefaultView[t3]["pageId"].ToString());
        //            t3 += 1;
        //            break;
        //        }
        //    }
        //    CheckBox tranCb1 = new CheckBox();
        //    tranCb1 = (CheckBox)devManage.Rows[j].FindControl("chbdevManage" + j + "1");
        //    if (tranCb1.Checked)
        //    {
        //        addPrv = 1;
        //    }
        //    CheckBox tranCb2 = new CheckBox();
        //    tranCb2 = (CheckBox)devManage.Rows[j].FindControl("chbdevManage" + j + "2");
        //    if (tranCb2.Checked)
        //    {
        //        viewPrv = 1;
        //    }
        //    CheckBox tranCb3 = new CheckBox();
        //    tranCb3 = (CheckBox)devManage.Rows[j].FindControl("chbdevManage" + j + "3");
        //    if (tranCb3.Checked)
        //    {
        //        modifyPrv = 1;
        //    }
        //    CheckBox tranCb4 = new CheckBox();
        //    tranCb4 = (CheckBox)devManage.Rows[j].FindControl("chbdevManage" + j + "4");
        //    if (tranCb4.Checked)
        //    {
        //        deletePrv = 1;
        //    }
        //    objUserRight.insertUserRights(Convert.ToInt16(Session["gid"]), pageId, pageGroup, addPrv, modifyPrv, deletePrv, viewPrv, employeeId);
        //    ds.Tables[0].DefaultView.RowFilter = " ";
        //}
        //int r3 = 0;
        //for (k = 0; k < reportCount - 1; k++)
        //{
        //    int pageGroup = 3;
        //    int pageId = 0;
        //    int addPrv = 0, modifyPrv = 0, deletePrv = 0, viewPrv = 0;
        //    ds.Tables[0].DefaultView.RowFilter = "parentId = '" + 3 + "'";
        //    if (ds.Tables[0].DefaultView.Count > 0)
        //    {
        //        while (r3 < reportCount - 1)
        //        {
        //            pageId = Convert.ToInt32(ds.Tables[0].DefaultView[r3]["pageId"].ToString());
        //            r3 += 1;
        //            break;
        //        }
        //    }
        //    CheckBox reportCb2 = new CheckBox();
        //    reportCb2 = (CheckBox)report.Rows[k].FindControl("chbReport" + k + "2");
        //    if (reportCb2.Checked)
        //    {
        //        viewPrv = 1;
        //    }
        //    objUserRight.insertUserRights(Convert.ToInt16(Session["gid"]), pageId, pageGroup, addPrv, modifyPrv, deletePrv, viewPrv, employeeId);
        //    ds.Tables[0].DefaultView.RowFilter = " ";
        //}
        //int o3 = 0;
        //for (l = 0; l < osCount - 1; l++)
        //{
        //    int pageGroup = 4;
        //    int pageId = 0;
        //    int addPrv = 0, modifyPrv = 0, deletePrv = 0, viewPrv = 0;
        //    ds.Tables[0].DefaultView.RowFilter = "parentId = '" + 4 + "'";
        //    if (ds.Tables[0].DefaultView.Count > 0)
        //    {
        //        while (o3 < osCount - 1)
        //        {
        //            pageId = Convert.ToInt32(ds.Tables[0].DefaultView[o3]["pageId"].ToString());
        //            o3 += 1;
        //            break;
        //        }
        //    }
        //    CheckBox osCb1 = new CheckBox();
        //    osCb1 = (CheckBox)ShftManage.Rows[l].FindControl("chbOS" + l + "1");
        //    if (osCb1.Checked)
        //    {
        //        addPrv = 1;
        //    }
        //    CheckBox osCb2 = new CheckBox();
        //    osCb2 = (CheckBox)ShftManage.Rows[l].FindControl("chbOS" + l + "2");
        //    if (osCb2.Checked)
        //    {
        //        viewPrv = 1;
        //    }
        //    CheckBox osCb3 = new CheckBox();
        //    osCb3 = (CheckBox)ShftManage.Rows[l].FindControl("chbOS" + l + "3");
        //    if (osCb3.Checked)
        //    {
        //        modifyPrv = 1;
        //    }
        //    CheckBox osCb4 = new CheckBox();
        //    osCb4 = (CheckBox)ShftManage.Rows[l].FindControl("chbOS" + l + "4");
        //    if (osCb4.Checked)
        //    {
        //        deletePrv = 1;
        //    }
        //    objUserRight.insertUserRights(Convert.ToInt16(Session["gid"]), pageId, pageGroup, addPrv, modifyPrv, deletePrv, viewPrv, employeeId);
        //    ds.Tables[0].DefaultView.RowFilter = " ";
        //}
        //int s3 = 0;
        //for (m = 0; m < ssCouont - 1; m++)
        //{
        //    int pageGroup = 5;
        //    int pageId = 0;
        //    int addPrv = 0, modifyPrv = 0, deletePrv = 0, viewPrv = 0;
        //    ds.Tables[0].DefaultView.RowFilter = "parentId = '" + 5 + "'";
        //    if (ds.Tables[0].DefaultView.Count > 0)
        //    {
        //        while (s3 < ssCouont - 1)
        //        {
        //            pageId = Convert.ToInt32(ds.Tables[0].DefaultView[s3]["pageId"].ToString());
        //            s3 += 1;
        //            break;
        //        }
        //    }
        //    CheckBox ssCb1 = new CheckBox();
        //    ssCb1 = (CheckBox)sysSetting.Rows[m].FindControl("chbSS" + m + "1");
        //    if (ssCb1.Checked)
        //    {
        //        addPrv = 1;
        //    }
        //    CheckBox ssCb2 = new CheckBox();
        //    ssCb2 = (CheckBox)sysSetting.Rows[m].FindControl("chbSS" + m + "2");
        //    if (ssCb2.Checked)
        //    {
        //        viewPrv = 1;
        //    }
        //    CheckBox ssCb3 = new CheckBox();
        //    ssCb3 = (CheckBox)sysSetting.Rows[m].FindControl("chbSS" + m + "3");
        //    if (ssCb3.Checked)
        //    {
        //        modifyPrv = 1;
        //    }
        //    CheckBox ssCb4 = new CheckBox();
        //    ssCb4 = (CheckBox)sysSetting.Rows[m].FindControl("chbSS" + m + "4");
        //    if (ssCb4.Checked)
        //    {
        //        deletePrv = 1;
        //    }
        //    objUserRight.insertUserRights(Convert.ToInt16(Session["gid"]), pageId, pageGroup, addPrv, modifyPrv, deletePrv, viewPrv, employeeId);
        //    ds.Tables[0].DefaultView.RowFilter = " ";
        //}
        GenerateMenu();
        string strScript = "";
        strScript = strScript + "<script language='javascript'>";
        strScript = strScript + "alert('" + rm.GetString("Aler_Modulerightswillbereflectednexttimeyoulogon", ci) + "');";
        strScript = strScript + "location.replace('TA_UI_Master_groupView.aspx');";
        strScript = strScript + "</script>";
        ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", strScript, false);
    }
    #endregion

}