protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["USERID"] == null || Session["USERID"].ToString() == string.Empty)
     {
         Response.Redirect("Login.aspx");
         return;
     }
     if (!IsPostBack)
     {
         string sqlstr11;
         if (Convert.ToString(Session["ISDISTRIBUTOR"]) == "Y")
         {
             sqlstr11 = "Select Distinct I.StateCode Code,I.StateCode+'-'+LS.Name Name from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.STATECODE <>'' AND I.SITEID IN (" + ucRoleFilters.GetCommaSepartedSiteId() + ")";
         }
         else
         {
             sqlstr11 = "Select Distinct I.StateCode Code,I.StateCode+'-'+LS.Name Name from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.STATECODE <>'' ";
         }
         ddlState.Items.Add("Select...");
         baseObj.BindToDropDown(ddlState, sqlstr11, "Name", "Code");
         if (ddlState.Items.Count == 2)
         {
             ddlState.SelectedIndex = 1;
             ddlState_SelectedIndexChanged(sender, e);
         }
     }
     if (Convert.ToString(Session["LOGINTYPE"]) == "3")
     {
         phState.Visible = false;
         ucRoleFilters.ListSiteIdChanged += UcRoleFilters_ListSiteChange;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["USERID"] == null || Session["USERID"].ToString() == string.Empty)
            {
                Response.Redirect("Login.aspx");
                return;
            }
            if (!Page.IsPostBack)
            {
                CalendarExtender1.StartDate = Convert.ToDateTime("01-July-2017");
                txtFromDate.Text            = System.DateTime.Now.ToString("dd-MMM-yyyy");
                txtToDate.Text = System.DateTime.Now.ToString("dd-MMM-yyyy");
                GridDetail();

                lblMessage.Text = "";
                string sqlstr11;
                if (Convert.ToString(Session["ISDISTRIBUTOR"]) == "Y")
                {
                    sqlstr11 = "Select Distinct I.StateCode Code,I.StateCode+' -'+LS.Name  Name from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.STATECODE <>'' AND I.SITEID='" + Convert.ToString(Session["SiteCode"]) + "'";
                }
                else
                {
                    sqlstr11 = "Select Distinct I.StateCode Code,I.StateCode+' -'+LS.Name  Name from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.STATECODE <>'' ";
                }
                ddlState.Items.Add("Select...");
                baseobj.BindToDropDown(ddlState, sqlstr11, "Name", "Code");
                if (ddlState.Items.Count == 2)
                {
                    ddlState.SelectedIndex = 1;
                    ddlState_SelectedIndexChanged(sender, e);
                }
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["USERID"] == null || Session["USERID"].ToString() == string.Empty)
            {
                Response.Redirect("Login.aspx");
                return;
            }

            if (!IsPostBack)
            {
                string sqlstr = @"Select Distinct TC.Name,TC.Category as Code from  [ax].[ACXTARGETCATEGORY] TC ";
                ddlClaimCat.Items.Add("Select...");
                baseObj.BindToDropDown(ddlClaimCat, sqlstr, "Name", "Code");
                string sqlstr11;
                if (Convert.ToString(Session["ISDISTRIBUTOR"]) == "Y")
                {
                    sqlstr11 = "Select Distinct StateCode Code,StateCode+'-'+lg.NAME Name from [ax].[INVENTSITE] sa inner join ax.LOGISTICSADDRESSSTATE lg on lg.STATEID = sa.STATECODE where STATECODE<>'' AND SITEID='" + Convert.ToString(Session["SiteCode"]) + "' ";
                }
                else
                {
                    sqlstr11 = "Select Distinct StateCode Code,StateCode+'-'+lg.NAME Name from [ax].[INVENTSITE] sa inner join ax.LOGISTICSADDRESSSTATE lg on lg.STATEID = sa.STATECODE where STATECODE<>''";
                }
                ddlState.Items.Add("Select...");
                baseObj.BindToDropDown(ddlState, sqlstr11, "Name", "Code");
                if (ddlState.Items.Count == 2)
                {
                    ddlState.SelectedIndex = 1;
                    ddlCountry_SelectedIndexChanged(sender, e);
                }
                //ddlBusinessUnit.Items.Add("Select...");
                //ddlSiteId.Items.Add("Select...");
            }
        }
        protected void FillState()
        {
            //DataTable dt = new DataTable();

            //dt = new DataTable();
            //if (Convert.ToString(Session["ISDISTRIBUTOR"]) != "Y")
            //{
            //    ddlState.Items.Clear();
            //    string sqlstr11 = "Select Distinct I.StateCode Code,LS.Name from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.STATECODE <>''  ";
            //   // string sqlstr11 = @"Select I.StateCode StateCode,LS.Name as StateName,I.SiteId,I.Name as SiteName from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE ";
            //    ddlState.Items.Add("Select...");
            //    baseObj.BindToDropDown(ddlState, sqlstr11, "Name", "Code");
            //}
            //else
            //{
            //    ddlState.Items.Clear();
            //    ddlSiteId.Items.Clear();
            //    string sqlstr1 = @"Select I.StateCode StateCode,LS.Name as StateName,I.SiteId,I.Name as SiteName from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.SiteId = '" + Session["SiteCode"].ToString() + "'";
            //    baseObj.BindToDropDown(ddlState, sqlstr1, "StateName", "StateCode");
            //    baseObj.BindToDropDown(ddlSiteId, sqlstr1, "SiteName", "SiteId");
            //}
            string sqlstr = "";

            if (Convert.ToString(Session["ISDISTRIBUTOR"]) == "Y")
            {
                if (Convert.ToString(Session["LOGINTYPE"]) == "3")
                {
                    DataTable dt      = App_Code.Global.HierarchyDataTable(ref chkListHOS, ref chkListVP, ref chkListGM, ref chkListDGM, ref chkListRM, ref chkListZM, ref chkListASM, ref chkListEXECUTIVE);
                    DataTable dtState = dt.DefaultView.ToTable(true, "STATE", "STATENAME");
                    ddlState.Items.Clear();
                    DataRow dr = dtState.NewRow();
                    dr[0] = "--Select--";
                    dr[1] = "--Select--";

                    dtState.Rows.InsertAt(dr, 0);
                    ddlState.DataSource     = dtState;
                    ddlState.DataTextField  = "STATENAME";
                    ddlState.DataValueField = "STATE";
                    ddlState.DataBind();
                }
                else
                {
                    sqlstr = "Select Distinct I.StateCode Code,LS.Name from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.STATECODE <>'' AND I.SITEID='" + Convert.ToString(Session["SiteCode"]) + "'";
                    //ddlState.Items.Add("Select...");
                    baseObj.BindToDropDown(ddlState, sqlstr, "Name", "Code");
                }
            }
            else
            {
                sqlstr = "Select Distinct I.StateCode Code,LS.Name from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.STATECODE <>'' ";
                ddlState.Items.Add("Select...");
                baseObj.BindToDropDown(ddlState, sqlstr, "Name", "Code");
            }
            if (ddlState.Items.Count == 1)
            {
                ddlState.SelectedIndex = 1;
                ddlCountry_SelectedIndexChanged(null, null);
            }
        }
Пример #5
0
        public void FillBU()
        {
            DDLBusinessUnit.Items.Clear();
            string query = "select bm.bu_code,bu_desc from ax.acxsitebumapping sbp join ax.ACXBUMASTER bm on bm.bu_code = sbp.BU_CODE where SITEID = '" + Convert.ToString(Session["SiteCode"]) + "'";

            DDLBusinessUnit.Items.Add("All...");
            baseObj.BindToDropDown(DDLBusinessUnit, query, "bu_desc", "bu_code");
        }
Пример #6
0
        public void BindInvoiceNo()
        {
            drpInvNo.Items.Add("Select...");
            string query1 = "EXEC USP_GETSERVICEREVERSALINVOICE '" + Session["SiteCode"].ToString() + "','" + Session["DATAAREAID"].ToString() + "'";

            baseobj.BindToDropDown(drpInvNo, query1, "INVOICENO", "INVOICENO");
        }
Пример #7
0
        protected void FillBU()
        {
            string SiteList = "";

            foreach (System.Web.UI.WebControls.ListItem item in lstSiteId.Items)
            {
                if (item.Selected)
                {
                    if (SiteList == "")
                    {
                        SiteList += "'" + item.Value.ToString() + "'";
                    }
                    else
                    {
                        SiteList += ",'" + item.Value.ToString() + "'";
                    }
                }
            }
            ddlBuunit.Items.Clear();
            if (SiteList != "")
            {
                //string query = "select bm.bu_code,bu_desc from ax.acxsitebumapping sbp join ax.ACXBUMASTER bm on bm.bu_code = sbp.BU_CODE where SITEID = '" + Convert.ToString(Session["SiteCode"]) + "'";
                string query = "select distinct bm.bu_code,bu_desc from ax.acxsitebumapping sbp join ax.ACXBUMASTER bm on bm.bu_code = sbp.BU_CODE where SITEID in (" + SiteList + ")";
                ddlBuunit.Items.Insert(0, "All...");
                baseObj.BindToDropDown(ddlBuunit, query, "bu_desc", "bu_code");
            }
        }
 public void fillCustomerGroup()
 {
     try
     {
         query = "Select CUSTGROUP_CODE+'-'+CUSTGROUP_NAME as Name,CUSTGROUP_CODE from ax.ACXCUSTGROUPMASTER where DATAAREAID ='" + Session["DATAAREAID"].ToString() + "' and  Blocked = 0";
         drpCustomerGroup.Items.Clear();
         ListItem lst = new ListItem("All...", "");
         drpCustomerGroup.Items.Insert(0, lst);
         baseObj.BindToDropDown(drpCustomerGroup, query, "Name", "CUSTGROUP_CODE");
         drpCustomerGroup_SelectedIndexChanged(null, null);
     }
     catch (Exception ex)
     {
         ErrorSignal.FromCurrentContext().Raise(ex);
     }
 }
Пример #9
0
        protected void ddlBUnit()
        {
            string query = "select bm.bu_code,bu_desc from ax.acxsitebumapping sbp join ax.ACXBUMASTER bm on bm.bu_code = sbp.BU_CODE where SITEID = '" + Convert.ToString(Session["SiteCode"]) + "'";

            ddlBusinessUnit.Items.Add("...Select...");
            baseObj.BindToDropDown(ddlBusinessUnit, query, "bu_desc", "bu_code");
        }
 protected void FillCustomers()
 {
     try
     {
         string query = string.Empty;
         ddlCustomers.Items.Clear();
         //query = "select CUSTOMERCODE,CUSTOMERNAME from VW_GetSrvInvoiceSiteCustList WHERE SITEID = '" + Session["SITECODE"].ToString() + "'";
         query = "SELECT CUSTOMERCODE,CUSTOMERNAME FROM VW_GetSrvInvoiceSiteCustList WHERE SITEID = '" + Session["SITECODE"].ToString() + "' UNION " + "SELECT C.[CUSTOMER_CODE], C.[CUSTOMER_CODE] + ' - ' + ISNULL(C.[CUSTOMER_NAME], '') AS Customer FROM AX.ACXCUSTMASTER C JOIN AX.ACX_SDLINKING SD ON SD.SUBDISTRIBUTOR = C.CUSTOMER_CODE WHERE SD.OTHER_SITE = '" + Session["SiteCode"].ToString() + "' AND C.CUST_GROUP != 'CG0001'";
         ddlCustomers.Items.Add("Select...");
         baseObj.BindToDropDown(ddlCustomers, query, "CUSTOMERNAME", "CUSTOMERCODE");
     }
     catch (Exception ex)
     {
         lblMessage.Text    = ex.Message.ToString();
         lblMessage.Visible = true;
         ErrorSignal.FromCurrentContext().Raise(ex);
     }
 }
Пример #11
0
        protected void DDLWarehouseFrom_SelectedIndexChanged(object sender, EventArgs e)
        {
            CreamBell_DMS_WebApps.App_Code.Global obj = new CreamBell_DMS_WebApps.App_Code.Global();
            string query2 = "SELECT INVENTLOCATIONID,NAME FROM AX.inventlocation WHERE INVENTSITEID='" + Session["SiteCode"].ToString() + "' and INVENTLOCATIONID <> '" + DDLWarehouseFrom.SelectedValue + "'";

            DDLWarehouseTo.Items.Clear();
            DDLWarehouseTo.Items.Add("-Select-");
            obj.BindToDropDown(DDLWarehouseTo, query2, "NAME", "INVENTLOCATIONID");
        }
Пример #12
0
        protected void fillState()
        {
            ddlState.Items.Clear();
            string sqlstr = "";

            sqlstr = "Select Distinct I.StateCode Code,I.StateCode+'-'+LS.Name Name from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.STATECODE <>'' ";
            ddlState.Items.Add("ALL");
            baseObj.BindToDropDown(ddlState, sqlstr, "Name", "Code");
            ddlState_SelectedIndexChanged(null, null);
        }
 public void fillCustomerGroup()
 {
     try
     {
         query = "SELECT CUSTGROUP_CODE+'-'+CUSTGROUP_NAME AS Name,CUSTGROUP_CODE FROM AX.ACXCUSTGROUPMASTER WHERE DATAAREAID ='" + Session["DATAAREAID"].ToString() + "' AND  Blocked = 0";
         drpCustomerGroup.Items.Clear();
         ListItem lst = new ListItem("All...", "");
         drpCustomerGroup.Items.Insert(0, lst);
         baseObj.BindToDropDown(drpCustomerGroup, query, "Name", "CUSTGROUP_CODE");
         drpCustomerName.Items.Add("All...");
         drpCustomerGroup_SelectedIndexChanged(null, null);
     }
     catch (Exception ex)
     {
         LblMessage.Text    = "'Please Try Again!! !";
         LblMessage.Visible = true;
         ErrorSignal.FromCurrentContext().Raise(ex);
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["USERID"] == null || Session["USERID"].ToString() == string.Empty)
     {
         Response.Redirect("Login.aspx");
         return;
     }
     if (!IsPostBack)
     {
         ClearAll();
         string query = "select bm.bu_code,bu_desc from ax.acxsitebumapping sbp join ax.ACXBUMASTER bm on bm.bu_code = sbp.BU_CODE where SITEID = '" + Convert.ToString(Session["SiteCode"]) + "'";
         ddlBusinessUnit.Items.Add("All...");
         obj.BindToDropDown(ddlBusinessUnit, query, "bu_desc", "bu_code");
         //Session["SecProductDetails"] = null;
         //Session["MarketDistructionDetails"] = null;
         GetProduct();
         //GetCustomerGroup();
     }
 }
Пример #15
0
        private void FillReturnReasonType()
        {
            CreamBell_DMS_WebApps.App_Code.Global obj = new CreamBell_DMS_WebApps.App_Code.Global();

            string strQuery = "Select distinct DAMAGEREASON_CODE,DAMAGEREASON_CODE + '-(' + DAMAGEREASON_NAME +')' as RETURNREASON  from [ax].[ACXDAMAGEREASON]";

            DDLReason.Items.Clear();
            DDLReason.Items.Add("-Select-");
            obj.BindToDropDown(DDLReason, strQuery, "RETURNREASON", "DAMAGEREASON_CODE");
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     lblError.Text = "";
     if (!Page.IsPostBack)
     {
         Session["TargetIncentive"] = null;
         try{
             string sqlstr = @"select  distinct TC.Name,TC.Category as Code from [ax].[ACXTARGETCATEGORY] TC ";
             ddlClaimCategory.Items.Add("Select...");
             baseObj.BindToDropDown(ddlClaimCategory, sqlstr, "Name", "Code");
             ddlBUnit();
         }
         catch (Exception ex)
         {
             lblError.Text = ex.Message;
             ErrorSignal.FromCurrentContext().Raise(ex);
         }
     }
 }
Пример #17
0
        protected void fillSiteAndState()
        {
            string sqlstr           = "select * from ax.ACXSITEMENU where SITE_CODE ='" + Session["SiteCode"].ToString() + "'";
            object objcheckSitecode = baseObj.GetScalarValue(sqlstr);

            if (objcheckSitecode != null)
            {
                ddlState.Items.Clear();
                string sqlstr11 = "Select Distinct I.StateCode Code,LS.Name from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.STATECODE <>'' ORDER BY LS.Name ";
                ddlState.Items.Add("Select...");
                baseObj.BindToDropDown(ddlState, sqlstr11, "Name", "Code");
            }
            else
            {
                ddlState.Items.Clear();
                ddlSiteId.Items.Clear();
                string sqlstr1 = @"Select I.StateCode StateCode,LS.Name as StateName,I.SiteId,I.Name as SiteName from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.SiteId = '" + Session["SiteCode"].ToString() + "'  ORDER BY LS.Name";
                baseObj.BindToDropDown(ddlState, sqlstr1, "StateName", "StateCode");
                baseObj.BindToDropDown(ddlSiteId, sqlstr1, "SiteName", "SiteId");
            }
        }
Пример #18
0
        public void fillPlant()
        {
            //query = "select CASE WHEN LEN(A.[ACXPLANTCODE])>0 THEN A.[ACXPLANTCODE] ELSE A.[ACXPLANTNAME] END [ACXPLANTCODE], CASE WHEN LEN(A.[ACXPLANTCODE])>0 THEN A.[ACXPLANTNAME] ELSE (SELECT TOP 1 NAME FROM AX.INVENTSITE WHERE SITEID=A.ACXPLANTNAME) END [ACXPLANTNAME] from ax.inventsite A Where A.SITEID='" + Session["SITECODE"].ToString() + "' union select SITEID,NAME from AX.INVENTSITE A Where A.SITEID IN (SELECT DISTINCT OTHER_SITE FROM AX.ACX_SDLinking WHERE SubDistributor='" + Session["SITECODE"].ToString() + "' AND BLOCKED=0)";
            //drpPlant.Items.Clear();
            //drpPlant.Items.Add("--All--");
            //baseObj.BindToDropDown(drpPlant, query, "ACXPLANTNAME", "ACXPLANTCODE");

            query = "select distinct isnull(supplier_code,'7200') as suppliercode,isnull(supplier_code,'7200') + '-' +  isnull(IVS.NAME,'Devyani Food Industries Limited') AS suppliername from [ax].[ACXPURCHINVRECIEPTHEADER] PH left join [ax].[INVENTSITE] IVS on IVS.siteid=PH.supplier_code WHERE PH.SITE_CODE='" + Session["SITECODE"].ToString() + "' ";
            drpPlant.Items.Clear();
            drpPlant.Items.Add("--All--");
            baseObj.BindToDropDown(drpPlant, query, "suppliername", "suppliercode");
        }
Пример #19
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["USERID"] == null || Session["USERID"].ToString() == string.Empty)
     {
         Response.Redirect("Login.aspx");
         return;
     }
     if (!IsPostBack)
     {
         ClearAll();
         GetProduct();
         query = "exec ACX_GETVRS '" + Session["SiteCode"].ToString() + "'";
         //dt = obj.GetData(query);
         ddlVrs.Items.Clear();
         ddlVrs.Items.Add("Select...");
         obj.BindToDropDown(ddlVrs, query, "NAME", "CODE");
     }
 }
Пример #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblError.Text = "";
            if (!Page.IsPostBack)
            {
                try
                {
                    // string sqlstr = @"select  distinct TC.Name,TC.Category as Code from  [ax].[ACXTARGETTABLE] TT Inner Join [ax].[ACXTARGETCATEGORY] TC  on TT.TARGETCATEGORY = TC.Category and TT.DataAreaId = TC.DataAreaid ";
                    string sqlstr = @"select  distinct TC.Name,TC.Category as Code from  [ax].[ACXTARGETCATEGORY] TC ";
                    //  string sqlstr1 = @"Select Distinct TS.Name,TS.Subcategory from [ax].[ACXTARGETSUBCATEGORY] TS ";
                    ddlClaimCategory.Items.Add("Select...");
                    // ddlClaimSubCategory.Items.Add("Select...");
                    baseObj.BindToDropDown(ddlClaimCategory, sqlstr, "Name", "Code");
                    //baseObj.BindToDropDown(ddlClaimSubCategory, sqlstr1, "Name", "Code");

                    string sqlstr2 = @"Select Distinct PM.PSR_Code as Code,PM.PSR_Code +'-'+ PM.PSR_Name as Name from [ax].[ACXPSRCUSTLinkingMaster] PLM
                        inner join [ax].[ACXPSRMaster] PM on PLM.PSRCode = PM.PSR_Code
                        where Site_Code = '" + Session["SiteCode"].ToString() + "'";

                    ddlObjectCode.Items.Clear();
                    ddlObjectCode.Items.Add("Select...");
                    baseObj.BindToDropDown(ddlObjectCode, sqlstr2, "Name", "Code");
                    string query = "select bm.bu_code,bu_desc from ax.acxsitebumapping sbp join ax.ACXBUMASTER bm on bm.bu_code = sbp.BU_CODE where SITEID = '" + Convert.ToString(Session["SiteCode"]) + "'";
                    ddlBusinessUnit.Items.Add("Select...");
                    baseObj.BindToDropDown(ddlBusinessUnit, query, "bu_desc", "bu_code");


                    creataDataTabel();
                    ddlObjectType_SelectedIndexChanged(ddlObjectType, new EventArgs());
                }
                catch (Exception ex)
                {
                    lblError.Text = ex.Message;
                    ErrorSignal.FromCurrentContext().Raise(ex);
                }
            }
        }
Пример #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["USERID"] == null || Session["USERID"].ToString() == string.Empty)
            {
                Response.Redirect("Login.aspx");
                return;
            }
            if (!IsPostBack)
            {
                //string sqlstr11 = "Select Distinct StateCode Code,StateCode Name from [ax].[INVENTSITE] where STATECODE <>'' ";
                //ddlState.Items.Add("Select...");
                //baseObj.BindToDropDown(ddlState, sqlstr11, "Name", "Code");
                DDLBusinessUnit.Items.Clear();
                string query = "select bm.bu_code,bu_desc from ax.acxsitebumapping sbp join ax.ACXBUMASTER bm on bm.bu_code = sbp.BU_CODE where SITEID = '" + Convert.ToString(Session["SiteCode"]) + "'";
                DDLBusinessUnit.Items.Add("All...");
                baseObj.BindToDropDown(DDLBusinessUnit, query, "bu_desc", "bu_code");

                fillSiteAndState();
            }
        }
        protected void fillSiteAndState(DataTable dt)
        {
            string sqlstr = "";

            if (Convert.ToString(Session["ISDISTRIBUTOR"]) == "Y")
            {
                if (Convert.ToString(Session["LOGINTYPE"]) == "3")
                {
                    DataTable dtState = dt.DefaultView.ToTable(true, "STATE", "STATEWNAME");
                    // dtState.Columns.Add("STATENAMES", typeof(string), "STATE + ' - ' + STATENAME");
                    ddlState.Items.Clear();
                    DataRow dr = dtState.NewRow();
                    dr[0] = "--Select--";
                    dr[1] = "--Select--";

                    dtState.Rows.InsertAt(dr, 0);
                    ddlState.DataSource     = dtState;
                    ddlState.DataTextField  = "STATEWNAME";
                    ddlState.DataValueField = "STATE";
                    ddlState.DataBind();
                }
                else
                {
                    sqlstr = "Select Distinct I.StateCode Code,I.StateCode+'-'+LS.Name Name from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.STATECODE <>'' AND I.SITEID='" + Convert.ToString(Session["SiteCode"]) + "'";
                    //ddlState.Items.Add("Select...");
                    baseObj.BindToDropDown(ddlState, sqlstr, "Name", "Code");
                }
            }
            else
            {
                sqlstr = "Select Distinct I.StateCode Code,I.StateCode+'-'+LS.Name Name from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.STATECODE <>'' ";
                ddlState.Items.Add("Select...");
                baseObj.BindToDropDown(ddlState, sqlstr, "Name", "Code");
            }
            if (ddlState.Items.Count == 1)
            {
                ddlState.SelectedIndex = 1;
                ddlCountry_SelectedIndexChanged(null, null);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["USERID"] == null || Session["USERID"].ToString() == string.Empty)
            {
                Response.Redirect("Login.aspx");
                return;
            }
            if (!IsPostBack)
            {
                baseObj.FillSaleHierarchy();
                BindProductGroup();
                fillHOS();
                //fillSiteAndState(null);


                if (Convert.ToString(Session["LOGINTYPE"]) == "3")
                {
                    // DataView DtSaleHierarchy = (DataTable)HttpContext.Current.Session["SaleHierarchy"];
                    DataTable dt = App_Code.Global.HierarchyDataTable(ref chkListHOS, ref chkListVP, ref chkListGM, ref chkListDGM, ref chkListRM, ref chkListZM, ref chkListASM, ref chkListEXECUTIVE);
                    if (dt.Rows.Count > 0)
                    {
                        var dr_row = dt.AsEnumerable();
                        var test   = (from r in dr_row
                                      select r.Field <string>("SALEPOSITION")).First <string>();



                        //string dr1 = dt.Select("SALEPOSITION").ToString();
                        if (test == "VP")
                        {
                            chkListHOS.Enabled = false;
                            chkAll.Enabled     = false;
                            chkAll.Checked     = true;
                            //  chkAll_CheckedChanged(null, null);
                        }
                        else if (test == "GM")
                        {
                            chkListHOS.Enabled = false;
                            chkListVP.Enabled  = false;
                            chkAll.Enabled     = false;
                            chkAll.Checked     = true;
                            CheckBox1.Enabled  = false;
                            CheckBox1.Checked  = true;
                            //    chkAll_CheckedChanged(null, null);
                        }
                        else if (test == "DGM")
                        {
                            chkListHOS.Enabled = false;
                            chkListVP.Enabled  = false;
                            chkListGM.Enabled  = false;
                            chkAll.Enabled     = false;
                            chkAll.Checked     = true;
                            CheckBox1.Enabled  = false;
                            CheckBox1.Checked  = true;
                            CheckBox2.Enabled  = false;
                            CheckBox2.Checked  = true;
                            //chkAll_CheckedChanged(null, null);
                        }
                        else if (test == "RM")
                        {
                            chkListHOS.Enabled = false;
                            chkListVP.Enabled  = false;
                            chkListGM.Enabled  = false;
                            chkListDGM.Enabled = false;
                            chkAll.Enabled     = false;
                            chkAll.Checked     = true;
                            CheckBox1.Enabled  = false;
                            CheckBox1.Checked  = true;
                            CheckBox2.Enabled  = false;
                            CheckBox2.Checked  = true;
                            CheckBox3.Enabled  = false;
                            CheckBox3.Checked  = true;
                            //chkAll_CheckedChanged(null, null);
                        }
                        else if (test == "ZM")
                        {
                            chkListHOS.Enabled = false;
                            chkListVP.Enabled  = false;
                            chkListGM.Enabled  = false;
                            chkListDGM.Enabled = false;
                            chkListRM.Enabled  = false;
                            chkAll.Enabled     = false;
                            chkAll.Checked     = true;
                            CheckBox1.Enabled  = false;
                            CheckBox1.Checked  = true;
                            CheckBox2.Enabled  = false;
                            CheckBox2.Checked  = true;
                            CheckBox3.Enabled  = false;
                            CheckBox3.Checked  = true;
                            CheckBox4.Enabled  = false;
                            CheckBox4.Checked  = true;
                            // chkAll_CheckedChanged(null, null);
                        }
                        else if (test == "ASM")
                        {
                            chkListHOS.Enabled = false;
                            chkListVP.Enabled  = false;
                            chkListGM.Enabled  = false;
                            chkListDGM.Enabled = false;
                            chkListRM.Enabled  = false;
                            chkListZM.Enabled  = false;
                            chkAll.Enabled     = false;
                            chkAll.Checked     = true;
                            CheckBox1.Enabled  = false;
                            CheckBox1.Checked  = true;
                            CheckBox2.Enabled  = false;
                            CheckBox2.Checked  = true;
                            CheckBox3.Enabled  = false;
                            CheckBox3.Checked  = true;
                            CheckBox4.Enabled  = false;
                            CheckBox4.Checked  = true;
                            CheckBox5.Enabled  = false;
                            CheckBox5.Checked  = true;
                            // chkAll_CheckedChanged(null, null);
                        }
                        else if (test == "EXECUTIVE")
                        {
                            chkListHOS.Enabled       = false;
                            chkListVP.Enabled        = false;
                            chkListGM.Enabled        = false;
                            chkListDGM.Enabled       = false;
                            chkListRM.Enabled        = false;
                            chkListZM.Enabled        = false;
                            chkListEXECUTIVE.Enabled = false;
                            chkAll.Enabled           = false;
                            chkAll.Checked           = true;
                            CheckBox1.Enabled        = false;
                            CheckBox1.Checked        = true;
                            CheckBox2.Enabled        = false;
                            CheckBox2.Checked        = true;
                            CheckBox3.Enabled        = false;
                            CheckBox3.Checked        = true;
                            CheckBox4.Enabled        = false;
                            CheckBox4.Checked        = true;
                            CheckBox5.Enabled        = false;
                            CheckBox5.Checked        = true;
                            CheckBox6.Enabled        = false;
                            CheckBox6.Checked        = true;

                            // chkAll_CheckedChanged(null, null);
                        }
                    }
                }
                if (Convert.ToString(Session["LOGINTYPE"]) == "3")
                {
                    tclink.Width        = "10%";
                    tclabel.Width       = "90%";
                    Panel1.Visible      = true;
                    LinkButton1.Visible = true;
                }
                else
                {
                    tclink.Width        = "0%";
                    tclabel.Width       = "100%";
                    Panel1.Visible      = false;
                    LinkButton1.Visible = false;
                    LinkButton1.Enabled = false;
                }


                string sqlstr = "";
                if (Convert.ToString(Session["ISDISTRIBUTOR"]) == "Y")
                {
                    if (Convert.ToString(Session["LOGINTYPE"]) == "3")
                    {
                        DataTable dt      = App_Code.Global.HierarchyDataTable(ref chkListHOS, ref chkListVP, ref chkListGM, ref chkListDGM, ref chkListRM, ref chkListZM, ref chkListASM, ref chkListEXECUTIVE);
                        DataTable dtState = dt.DefaultView.ToTable(true, "STATE", "STATENAME");
                        ddlState.Items.Clear();
                        DataRow dr = dtState.NewRow();
                        if (dtState.Rows.Count >= 2)
                        {
                            dr[0] = "Select...";
                            dtState.Rows.InsertAt(dr, 0);
                        }
                        ddlState.DataSource     = dtState;
                        ddlState.DataTextField  = "STATENAME";
                        ddlState.DataValueField = "STATE";
                        ddlState.DataBind();
                    }
                    else
                    {
                        ddlState.Items.Clear();
                        sqlstr = "Select Distinct I.StateCode Code,LS.Name from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.STATECODE <>'' AND I.SITEID='" + Convert.ToString(Session["SiteCode"]) + "'";
                        baseObj.BindToDropDown(ddlState, sqlstr, "Name", "Code");
                    }
                }
                else
                {
                    ddlState.Items.Clear();
                    sqlstr = "Select Distinct I.StateCode Code,LS.Name from [ax].[INVENTSITE] I left join [ax].[LOGISTICSADDRESSSTATE] LS on LS.STATEID = I.STATECODE where I.STATECODE <>'' ";
                    ddlState.Items.Add("Select...");
                    baseObj.BindToDropDown(ddlState, sqlstr, "Name", "Code");
                }
                if (ddlState.Items.Count == 1)
                {
                    ddlState.SelectedIndex = 1;
                    ddlCountry_SelectedIndexChanged(null, null);
                }
                ddlCountry_SelectedIndexChanged(null, null);
                ddlSiteId_SelectedIndexChanged(null, null);
            }
        }
        protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
        {
            try {
                if (ddlState.SelectedItem.Text == "All...")
                {
                    DataTable dt = App_Code.Global.HierarchyDataTable(ref chkListHOS, ref chkListVP, ref chkListGM, ref chkListDGM, ref chkListRM, ref chkListZM, ref chkListASM, ref chkListEXECUTIVE);

                    //DataTable uniqueCols = dt.DefaultView.ToTable(true, "Distributor", "DistributorName");

                    DataView  view           = new DataView(dt);
                    DataTable distinctValues = view.ToTable(true, "Distributor", "DistributorName");
                    distinctValues.Columns.Add("Name", typeof(string), "Distributor + ' - ' + DistributorName");
                    ddlSiteId.DataSource     = distinctValues;
                    ddlSiteId.DataTextField  = "Name";
                    ddlSiteId.DataValueField = "Distributor";
                    ddlSiteId.DataBind();
                    //ddlSiteId.Items.Add("All...");
                    ddlSiteId.Items.Insert(0, "All...");
                }

                else
                {
                    string sqlstr           = "select * from ax.ACXSITEMENU where SITE_CODE ='" + Session["SiteCode"].ToString() + "'";
                    object objcheckSitecode = baseObj.GetScalarValue(sqlstr);
                    if (objcheckSitecode != null)
                    {
                        ddlSiteId.Items.Clear();
                        string sqlstr1 = @"Select Distinct SITEID as Code,SITEID +' - '+ NAME as NAME from [ax].[INVENTSITE] where STATECODE = '" + ddlState.SelectedItem.Value + "'";
                        ddlSiteId.Items.Insert(0, "All...");
                        baseObj.BindToDropDown(ddlSiteId, sqlstr1, "Name", "Code");
                    }
                    else
                    {
                        ddlSiteId.Items.Clear();
                        if (Convert.ToString(Session["LOGINTYPE"]) == "3")
                        {
                            // DataTable dt = (DataTable)Session["SaleHierarchy"];
                            DataTable dt = App_Code.Global.HierarchyDataTable(ref chkListHOS, ref chkListVP, ref chkListGM, ref chkListDGM, ref chkListRM, ref chkListZM, ref chkListASM, ref chkListEXECUTIVE);
                            dt.DefaultView.RowFilter = "STATE='" + ddlState.SelectedItem.Value.Trim() + "'";
                            DataTable uniqueCols = dt.DefaultView.ToTable(true, "Distributor", "DistributorName");

                            uniqueCols.Columns.Add("Name", typeof(string), "Distributor + ' - ' + DistributorName");

                            ddlSiteId.DataSource     = uniqueCols;
                            ddlSiteId.DataTextField  = "Name";
                            ddlSiteId.DataValueField = "distributor";
                            ddlSiteId.DataBind();
                            ddlSiteId.Items.Insert(0, "All...");
                        }
                        else
                        {
                            string sqlstr1 = @"Select Distinct SITEID as Code,SITEID +' - '+ NAME as NAME from [ax].[INVENTSITE] where SITEID = '" + Session["SiteCode"].ToString() + "'";
                            //ddlSiteId.Items.Add("All...");

                            baseObj.BindToDropDown(ddlSiteId, sqlstr1, "Name", "Code");
                        }
                    }
                }
            }
            catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); }
        }