Exemplo n.º 1
0
        protected void FillState()
        {
            string    sqlstr           = "select * from ax.ACXSITEMENU where SITE_CODE ='" + Session["SiteCode"].ToString() + "'";
            object    objcheckSitecode = baseObj.GetScalarValue(sqlstr);
            DataTable dt = new DataTable();

            dt = new DataTable();
            if (objcheckSitecode != null)
            {
                chkListState.Items.Clear();
                string 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 <>''  ";
                dt = baseObj.GetData(sqlstr11);
                //chkListState.Items.Add("All...");
                chkListState.DataSource     = dt;
                chkListState.DataTextField  = "NAME";
                chkListState.DataValueField = "Code";
                chkListState.DataBind();
                //chkListState.Items.Insert(0, new ListItem("All..."));
                //for (int i = 0; i < dt.Rows.Count; i++)
                //{
                //    chkListState.DataSource = dt;
                //    chkListState.DataTextField = "NAME";
                //    chkListState.DataValueField = "Code";
                //    chkListState.DataBind();
                //}
            }
            else
            {
                chkListState.Items.Clear();
                chkListSite.Items.Clear();
                string sqlstr1 = @"Select I.StateCode StateCode,I.StateCode+'-'+LS.Name as StateName,I.SiteId,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() + "'";
                dt = baseObj.GetData(sqlstr1);
                chkListState.DataSource     = dt;
                chkListState.DataTextField  = "StateName";
                chkListState.DataValueField = "StateCode";
                chkListState.DataBind();

                chkListSite.DataSource     = dt;
                chkListSite.DataTextField  = "SiteName";
                chkListSite.DataValueField = "SiteId";
                chkListSite.DataBind();
                //for (int i = 0; i < dt.Rows.Count; i++)
                //{
                //    chkListState.DataSource = dt;
                //    chkListState.DataTextField = "StateName";
                //    chkListState.DataValueField = "StateCode";
                //    chkListState.DataBind();

                //    chkListSite.DataSource = dt;
                //    chkListSite.DataTextField = "SiteName";
                //    chkListSite.DataValueField = "SiteId";
                //    chkListSite.DataBind();
                //}
                if (dt.Rows.Count > 0)
                {
                    chkListState.Items[0].Selected = true;
                    chkListSite.Items[0].Selected  = true;
                }
            }
        }
Exemplo n.º 2
0
        protected void FillState()
        {
            try
            {
                string    sqlstr           = "select * from ax.ACXSITEMENU where SITE_CODE ='" + Session["SiteCode"].ToString() + "'";
                object    objcheckSitecode = baseObj.GetScalarValue(sqlstr);
                DataTable dt = new DataTable();

                dt = new DataTable();
                if (objcheckSitecode != null)
                {
                    chkListState.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 <>''  ";
                    dt = baseObj.GetData(sqlstr11);
                    chkListState.Items.Add("All...");
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        chkListState.DataSource     = dt;
                        chkListState.DataTextField  = "NAME";
                        chkListState.DataValueField = "Code";
                        chkListState.DataBind();
                    }
                }
                else
                {
                    chkListState.Items.Clear();
                    chkListSite.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() + "'";
                    dt = baseObj.GetData(sqlstr1);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        chkListState.DataSource     = dt;
                        chkListState.DataTextField  = "StateName";
                        chkListState.DataValueField = "StateCode";
                        chkListState.DataBind();

                        chkListSite.DataSource     = dt;
                        chkListSite.DataTextField  = "SiteName";
                        chkListSite.DataValueField = "SiteId";
                        chkListSite.DataBind();
                    }
                    chkListState.Items[0].Selected = true;
                    chkListSite.Items[0].Selected  = true;
                    FillCustomerGroup();
                }
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
        protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
        {
            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.Add("All...");
                baseObj.BindToDropDown(ddlSiteId, sqlstr1, "Name", "Code");
            }
            else
            {
                ddlSiteId.Items.Clear();
                if (Convert.ToString(Session["LOGINTYPE"]) == "3")
                {
                    //DataTable dt = (DataTable)Session["SaleHierarchy"];
                    // DataTable dt = HierarchyDataTable(ref chkListHOS, ref chkListVP, ref chkListGM, ref chkListDGM, ref chkListRM, ref chkListZM, ref chkListASM);
                    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");

                    ddlSiteId.DataSource     = uniqueCols;
                    ddlSiteId.DataTextField  = "DistributorName";
                    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() + "'";
                    baseObj.BindToDropDown(ddlSiteId, sqlstr1, "Name", "Code");
                }
            }
        }
Exemplo n.º 4
0
        protected void DDLProductDesc_SelectedIndexChanged(object sender, EventArgs e)
        {
            //===========Fill Product Group and Product Sub Cat========
            DataTable dt    = new DataTable();
            string    query = "select Product_Group,PRODUCT_SUBCATEGORY  from ax.INVENTTABLE where ItemId='" + DDLProductDesc.SelectedValue.ToString() + "' order by Product_Name";

            dt = baseObj.GetData(query);
            if (dt.Rows.Count > 0)
            {
                DDLProductGroup.Text = dt.Rows[0]["PRODUCT_GROUP"].ToString();
                ProductSubCategory();
                //=============For Product Sub Cat======
                DDLProdSubCategory.Text = dt.Rows[0]["PRODUCT_SUBCATEGORY"].ToString();

                CreamBell_DMS_WebApps.App_Code.Global obj = new CreamBell_DMS_WebApps.App_Code.Global();
                string queryStock = " Select isnull(SUM(INVTS.TRANSQTY),0) AS STOCK From AX.ACXINVENTTRANS INVTS INNER JOIN AX.INVENTTABLE INV  ON INV.ITEMID= INVTS.PRODUCTCODE " +
                                    " WHERE INVTS.DATAAREAID='" + Session["DATAAREAID"] + "' AND INVTS.SiteCode='" + Session["SiteCode"] + "' " +
                                    " AND INVTS.TRANSLOCATION='" + DDLWarehouseFrom.SelectedValue.Trim().ToString() + "' " +
                                    " AND INVTS.PRODUCTCODE ='" + DDLProductDesc.SelectedValue.ToString() + "'";

                object stockValue = obj.GetScalarValue(queryStock);
                if (stockValue != null)
                {
                    txtstock.Text = Convert.ToDecimal(stockValue.ToString()).ToString("0.00");
                }
            }
        }
Exemplo n.º 5
0
        protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
        {
            string usertype         = string.Empty;
            string sqlstr           = "select * from ax.ACXSITEMENU where SITE_CODE ='" + Session["SiteCode"].ToString() + "'";
            object objcheckSitecode = baseObj.GetScalarValue(sqlstr);

            if (objcheckSitecode != null)
            {
                usertype = ddlUserType.SelectedItem.Value.ToString();
                DataTable dtDataByfilter = null;
                string    query          = string.Empty;
                try
                {
                    ddlUsers.Items.Clear();
                    conn = new SqlConnection(baseObj.GetConnectionString());
                    conn.Open();
                    cmd                = new SqlCommand();
                    cmd.Connection     = conn;
                    cmd.CommandTimeout = 3600;
                    cmd.CommandType    = CommandType.StoredProcedure;
                    query              = "USP_FILLUSERSINDROPDOWN";

                    cmd.CommandText = query;
                    if (ddlState.SelectedItem.Text == "ALL")
                    {
                        cmd.Parameters.AddWithValue("@STATECODE", "");
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@STATECODE", ddlState.SelectedItem.Value);
                    }
                    cmd.Parameters.AddWithValue("@USERTYPE", usertype);
                    dtDataByfilter = new DataTable();
                    dtDataByfilter.Load(cmd.ExecuteReader());
                    if (dtDataByfilter.Rows.Count > 0)
                    {
                        ddlUsers.DataSource     = dtDataByfilter;
                        ddlUsers.DataTextField  = "Name";
                        ddlUsers.DataValueField = "Code";
                        ddlUsers.DataBind();
                    }
                    ddlUsers.Items.Insert(0, "ALL");
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }
Exemplo n.º 6
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,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, sqlstr11, "Name", "Code");
            }
            else
            {
                ddlState.Items.Clear();
                ddlSiteId.Items.Clear();
                string sqlstr1 = @"Select I.StateCode StateCode,I.StateCode+'-'+LS.Name as StateName,I.SiteId,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");
            }
        }
        protected void FillSite()
        {
            string StateList = "";

            foreach (ListItem item in chkListState1.Items)
            {
                if (item.Selected)
                {
                    if (StateList == "")
                    {
                        StateList += "'" + item.Value.ToString() + "'";
                    }
                    else
                    {
                        StateList += ",'" + item.Value.ToString() + "'";
                    }
                }
            }
            if (StateList.Length > 0)
            {
                DataTable dt               = new DataTable();
                string    sqlstr1          = string.Empty;
                string    sqlstr           = "select * from ax.ACXSITEMENU where SITE_CODE  IN (" + ucRoleFilters.GetCommaSepartedSiteId() + ") ";
                object    objcheckSitecode = baseObj.GetScalarValue(sqlstr);
                if (Convert.ToString(Session["ISDISTRIBUTOR"]).ToUpper() != "Y")
                {
                    sqlstr1 = @"Select Distinct SITEID ,SITEID+'-'+NAME as SiteName from [ax].[INVENTSITE] where STATECODE in (" + StateList + ") order by SiteName";
                }
                else
                {
                    sqlstr1 = @"Select Distinct SITEID ,SITEID+'-'+NAME as SiteName from [ax].[INVENTSITE] where SITEID  IN (" + ucRoleFilters.GetCommaSepartedSiteId() + ") ";
                }

                dt = new DataTable();
                // dt = baseObj.GetData(sqlstr1);
                chkListSite1.Items.Clear();
                dt = baseObj.GetData(sqlstr1);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    chkListSite1.DataSource     = dt;
                    chkListSite1.DataTextField  = "SiteName";
                    chkListSite1.DataValueField = "SiteId";
                    chkListSite1.DataBind();
                }
            }
            else
            {
                chkListSite1.Items.Clear();
            }
        }
Exemplo n.º 8
0
        private bool ValidateStock(string ProductCode, decimal MoveQty)
        {
            bool stock = true;

            CreamBell_DMS_WebApps.App_Code.Global obj = new CreamBell_DMS_WebApps.App_Code.Global();

            string queryStock = " Select isnull(SUM(INVTS.TRANSQTY),0) AS STOCK From AX.ACXINVENTTRANS INVTS INNER JOIN AX.INVENTTABLE INV  ON INV.ITEMID= INVTS.PRODUCTCODE " +
                                " WHERE INVTS.DATAAREAID='" + Session["DATAAREAID"] + "' AND INVTS.SiteCode='" + Session["SiteCode"] + "' " +
                                " AND INVTS.TRANSLOCATION='" + DDLWarehouseFrom.SelectedValue.Trim().ToString() + "' " +
                                " AND INVTS.PRODUCTCODE ='" + ProductCode + "'";

            object stockValue = obj.GetScalarValue(queryStock);

            if (stockValue != null)
            {
                decimal AvailableStock = Math.Round(Convert.ToDecimal(stockValue.ToString()), 2);
                if (MoveQty <= AvailableStock)
                {
                    if (MoveQty + AvailableStock < 0)
                    {
                        stock = false;
                        //ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", " alert('Stock Negative Issue : Final Stock cannot be in negative figure. !');", true);
                        LblMessage.Text = "Stock Negative Issue : Final Stock cannot be in negative figure. !";
                    }
                    else
                    {
                        stock = true;
                    }
                }
                else
                {
                    stock = false;
                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", " alert('Stock Issue : Entered Value cannot be more than the available Stock !');", true);
                    LblMessage.Text = "Stock Issue : Entered Value cannot be more than the available Stock !";
                }
                //if (AdjusmentValue <= AvailableStock)
                //{
                //    stock = true;
                //}
                //else
                //{
                //    stock = false;
                //    ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", " alert('Stock Issue : Entered Value cannot be more than the available Stock !');", true);
                //}
            }
            return(stock);
        }
        private void ShowReportSummary()
        {
            CreamBell_DMS_WebApps.App_Code.Global obj = new CreamBell_DMS_WebApps.App_Code.Global();
            DataTable  dtSetData = null;
            SqlCommand cmd       = new SqlCommand();

            cmd.CommandTimeout = 0;

            try
            {
                string query = "Select Top 1 NAME from ax.inventsite where SITEID='" + Session["SiteCode"].ToString() + "'";
                object obj1  = obj.GetScalarValue(query);

                string sqlstr = @"Select I.Siteid,I.Name,I.StateCode,from_Date,To_Date,TC.Name as Cat,TS.Name as Subcat,Target_Description,Actual_Incentive,
                                    Case when Claim_Type = '0' then 'Sale' else 'Purchase' end as ClaimType 
                                    from [ax].[ACXCLAIMMASTER] CM 
                                    left join 
                                    [ax].[ACXTARGETCATEGORY] TC on CM.Claim_Category = TC.CATEGORY
                                    left join 
                                    [ax].[ACXTARGETSUBCATEGORY] TS on CM.CLAIM_SUBCATEGORY = TS.Subcategory
                                    left join 
                                    [ax].[INVENTSITE] I on CM.SITE_CODE = I.Siteid
                                    where CM.from_Date  >= " +
                                " '" + Convert.ToDateTime(txtFromDate.Text) + "' and CM.TO_DATE <= '" + Convert.ToDateTime(txtToDate.Text) + "'  ";
                //  "  ";

                if (ddlSiteId.SelectedIndex != -1)
                {
                    if (ddlSiteId.SelectedItem.Text != "Select...")
                    {
                        sqlstr += "and CM.SITE_CODE = '" + ddlSiteId.SelectedItem.Value + "'  ";
                    }
                }

                dtSetData = new DataTable();
                dtSetData = obj.GetData(sqlstr);

                LoadDataInReportViewerDetail(dtSetData);
            }
            catch (Exception ex)
            {
                LblMessage.Text = ex.Message.ToString();
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
Exemplo n.º 10
0
        public bool checkifDataAlreadyExist()
        {
            try {
                string ClaimType = "0";
                if (ddlObjectType.SelectedItem.Text == "PSR")
                {
                    ClaimType = "0";
                }
                if (ddlObjectType.SelectedItem.Text == "SITE")
                {
                    ClaimType = "1";
                }
                if (ddlObjectType.SelectedItem.Text == "CUSTOMERGROUP")
                {
                    ClaimType = "2";
                }

                string sqstr = @"Select * from [ax].[ACXCLAIMMASTER] where FROM_DATE ='" + txtFromDate.Text + "' and TO_DATE = '" + txttoDate.Text + "' " +
                               " and SITE_CODE = '" + Session["SiteCode"].ToString() + "' and CLAIM_CATEGORY= '" + ddlClaimCategory.SelectedItem.Value + "' " +
                               " and CLAIM_TYPE = '" + ClaimType + "'  and OBJECT_CODE = '" + ddlObjectCode.SelectedItem.Value + "' and BU_CODE= '" + ddlBusinessUnit.SelectedItem.Value + "'";

                if (ddlClaimSubCategory.SelectedIndex > 0)
                {
                    sqstr += " and CLAIM_SUBCATEGORY = '" + ddlClaimSubCategory.SelectedItem.Value + "' ";
                }

                object obj = baseObj.GetScalarValue(sqstr);
                if (obj != null)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", " alert('Data already exist for combination.. !');", true);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
                ErrorSignal.FromCurrentContext().Raise(ex);
                return(false);
            }
        }
Exemplo n.º 11
0
        protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string statesel = "";
                foreach (System.Web.UI.WebControls.ListItem litem1 in lstState.Items)
                {
                    if (litem1.Selected)
                    {
                        if (statesel.Length == 0)
                        {
                            statesel = "'" + litem1.Value.ToString() + "'";
                        }
                        else
                        {
                            statesel += ",'" + litem1.Value.ToString() + "'";
                        }
                    }
                }
                if (lstState.SelectedValue == string.Empty)
                {
                    lstSiteId.Items.Clear();
                    DataTable dt = App_Code.Global.HierarchyDataTable(ref chkListHOS, ref chkListVP, ref chkListGM, ref chkListDGM, ref chkListRM, ref chkListZM, ref chkListASM, ref chkListEXECUTIVE);

                    DataView  view           = new DataView(dt);
                    DataTable distinctValues = view.ToTable(true, "Distributor", "DistributorName");
                    lstSiteId.DataSource = distinctValues;
                    string AllSitesFromHierarchy = "";
                    foreach (DataRow row in distinctValues.Rows)
                    {
                        if (AllSitesFromHierarchy == "")
                        {
                            AllSitesFromHierarchy += "'" + row["Distributor"].ToString() + "'";
                        }
                        else
                        {
                            AllSitesFromHierarchy += ",'" + row["Distributor"].ToString() + "'";
                        }
                    }
                    if (AllSitesFromHierarchy != "")
                    {
                        string sqlstr1 = @"Select Distinct SITEID as Code,SITEID +' - '+ Name AS Name,Name as SiteName from [ax].[INVENTSITE] IV LEFT JOIN AX.ACXUSERMASTER UM on IV.SITEID = UM.SITE_CODE where UM.DEACTIVATIONDATE = '1900-01-01 00:00:00.000' AND SITEID IN (" + AllSitesFromHierarchy + ") Order by SiteName ";
                        dt = baseObj.GetData(sqlstr1);
                        lstSiteId.DataSource     = dt;
                        lstSiteId.DataTextField  = "Name";
                        lstSiteId.DataValueField = "Code";
                        lstSiteId.DataBind();
                    }
                }
                else
                {
                    string sqlstr           = "select * from ax.ACXSITEMENU where SITE_CODE ='" + Session["SiteCode"].ToString() + "'";
                    object objcheckSitecode = baseObj.GetScalarValue(sqlstr);
                    if (objcheckSitecode != null)
                    {
                        lstSiteId.Items.Clear();
                        string    sqlstr1 = @"Select Distinct SITEID as Code,SITEID + ' - ' + NAME AS NAME,Name as SiteName from [ax].[INVENTSITE] IV JOIN AX.ACXUSERMASTER UM on IV.SITEID=UM.SITE_CODE where STATECODE in (" + statesel + ") AND  UM.DEACTIVATIONDATE = '1900-01-01 00:00:00.000' Order by SiteName";
                        DataTable dt      = baseObj.GetData(sqlstr1);
                        lstSiteId.DataSource     = dt;
                        lstSiteId.DataTextField  = "Name";
                        lstSiteId.DataValueField = "Code";
                        lstSiteId.DataBind();
                    }
                    else
                    {
                        lstSiteId.Items.Clear();
                        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);
                            dt.DefaultView.RowFilter = "STATE in (" + statesel + ")";
                            DataTable uniqueCols            = dt.DefaultView.ToTable(true, "Distributor", "DistributorName");
                            string    AllSitesFromHierarchy = "";
                            foreach (DataRow row in uniqueCols.Rows)
                            {
                                if (AllSitesFromHierarchy == "")
                                {
                                    AllSitesFromHierarchy += "'" + row["Distributor"].ToString() + "'";
                                }
                                else
                                {
                                    AllSitesFromHierarchy += ",'" + row["Distributor"].ToString() + "'";
                                }
                            }
                            string sqlstr1 = @"Select Distinct SITEID as Code,SITEID +' - '+ Name AS Name,Name as SiteName from [ax].[INVENTSITE] IV LEFT JOIN AX.ACXUSERMASTER UM on IV.SITEID = UM.SITE_CODE where UM.DEACTIVATIONDATE = '1900-01-01 00:00:00.000' AND SITEID IN (" + AllSitesFromHierarchy + ") Order by SiteName ";
                            dt = baseObj.GetData(sqlstr1);
                            lstSiteId.DataSource     = dt;
                            lstSiteId.DataTextField  = "Name";
                            lstSiteId.DataValueField = "Code";
                            lstSiteId.DataBind();
                        }
                        else
                        {
                            string    sqlstr1 = @"Select Distinct SITEID as Code,SITEID + ' - ' + NAME AS NAME from [ax].[INVENTSITE] IV JOIN AX.ACXUSERMASTER UM on IV.SITEID=UM.SITE_CODE where SITEID = '" + Session["SiteCode"].ToString() + "' AND UM.DEACTIVATIONDATE = '1900-01-01 00:00:00.000'";
                            DataTable dt      = baseObj.GetData(sqlstr1);
                            lstSiteId.DataSource     = dt;
                            lstSiteId.DataTextField  = "Name";
                            lstSiteId.DataValueField = "Code";
                            lstSiteId.DataBind();
                        }
                    }
                }
                if (lstSiteId.Items.Count == 1)
                {
                    foreach (System.Web.UI.WebControls.ListItem litem in lstSiteId.Items)
                    {
                        litem.Selected = true;
                    }
                    FillBU();
                }
                Session["SalesData"] = App_Code.Global.HierarchyDataTable(ref chkListHOS, ref chkListVP, ref chkListGM, ref chkListDGM, ref chkListRM, ref chkListZM, ref chkListASM, ref chkListEXECUTIVE);
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
Exemplo n.º 12
0
 protected void FillSite()
 {
     try
     {
         string StateList = "";
         foreach (ListItem item in lstSTATE.Items)
         {
             if (item.Selected)
             {
                 if (StateList == "")
                 {
                     StateList += "'" + item.Value.ToString() + "'";
                 }
                 else
                 {
                     StateList += ",'" + item.Value.ToString() + "'";
                 }
             }
         }
         if (StateList.Length > 0)
         {
             string sqlstr           = "select * from ax.ACXSITEMENU where SITE_CODE ='" + Session["SiteCode"].ToString() + "'";
             object objcheckSitecode = baseObj.GetScalarValue(sqlstr);
             if (objcheckSitecode != null)
             {
                 lstDIS.Items.Clear();
                 string sqlstr1 = @"Select Distinct SITEID as Code,SITEID+'-'+Name Name from [ax].[INVENTSITE] where STATECODE in (" + StateList + ") Order by Name";
                 lstDIS.Items.Add("All...");
                 DataTable dt1 = new DataTable();
                 dt1 = baseObj.GetData(sqlstr1);
                 lstDIS.DataSource     = dt1;
                 lstDIS.DataTextField  = "Name";
                 lstDIS.DataValueField = "Code";
                 lstDIS.DataBind();
             }
             else
             {
                 lstDIS.Items.Clear();
                 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 uniqueCols = dt.DefaultView.ToTable(true, "Distributor", "DistributorName");
                     uniqueCols.Columns.Add("Name", typeof(string), "Distributor + ' - ' + DistributorName");
                     lstDIS.DataSource     = uniqueCols;
                     lstDIS.DataTextField  = "Name";
                     lstDIS.DataValueField = "distributor";
                     lstDIS.DataBind();
                 }
                 else
                 {
                     string sqlstr1 = @"Select Distinct SITEID as Code,SITEID+'-'+NAME Name from [ax].[INVENTSITE] where SITEID = '" + Session["SiteCode"].ToString() + "'";
                     //drpDIS.Items.Add("All...");
                     DataTable dt1 = new DataTable();
                     dt1 = baseObj.GetData(sqlstr1);
                     lstDIS.DataSource     = dt1;
                     lstDIS.DataTextField  = "Name";
                     lstDIS.DataValueField = "Code";
                     lstDIS.DataBind();
                 }
                 if (lstDIS.Items.Count == 1)
                 {
                     CheckBox8.Visible        = false;
                     lstDIS.Items[0].Selected = true;
                     lstDIS_SelectedIndexChanged(null, null);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ErrorSignal.FromCurrentContext().Raise(ex);
     }
 }
        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); }
        }
        protected void drpRecieptNo_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                DropDownList ddllist             = (DropDownList)sender;
                object       objcheckproductcode = null;
                if (ddllist.ID == "ddlInvoceNo")
                {
                    query = "Select Top 1 A.PURCH_RECIEPTNO from [ax].[ACXPURCHINVRECIEPTHEADER] A where A.[SITE_Code]='" + Session["SiteCode"].ToString() + "' " +
                            "and A.[DATAAREAID]='" + Session["DATAAREAID"].ToString() + "' and A.[SALE_INVOICENO]='" + ddlInvoceNo.SelectedItem.Value + "' ";

                    objcheckproductcode = obj.GetScalarValue(query);

                    if (objcheckproductcode == null)
                    {
                        LblMessage.Text = "PURCH_RECIEPTNO Number Not Found";
                        return;
                    }
                    drpRecieptNo.SelectedIndex = drpRecieptNo.Items.IndexOf(drpRecieptNo.Items.FindByText(objcheckproductcode.ToString()));
                }
                else
                {
                    //=================Fill Header Part===============
                    string sqlstr = "Select Top 1 [SALE_INVOICENO] from [ax].[ACXPURCHINVRECIEPTHEADER] A where A.[SITE_Code]='" + Session["SiteCode"].ToString() + "' " +
                                    "and A.[DATAAREAID]='" + Session["DATAAREAID"].ToString() + "' and A.PURCH_RECIEPTNO='" + drpRecieptNo.SelectedItem.Text + "' ";

                    objcheckproductcode = obj.GetScalarValue(sqlstr);

                    if (objcheckproductcode == null)
                    {
                        LblMessage.Text = "Invoice Number Not Found";
                        return;
                    }
                    ddlInvoceNo.SelectedIndex = ddlInvoceNo.Items.IndexOf(ddlInvoceNo.Items.FindByText(objcheckproductcode.ToString()));
                }

                query = "Select A.[DOCUMENT_NO],CONVERT(VARCHAR(11),A.[DOCUMENT_DATE] ,106) as [DOCUMENT_DATE], A.PURCH_INDENTNO, CONVERT(VARCHAR(11),A.[PURCH_INDENTDATE],106) AS PURCH_INDENTDATE, " +
                        "A.MATERIAL_VALUE, A.PURCH_RECIEPTNO, A.TRANSPORTER_CODE,A.VEHICAL_NO, A.VEHICAL_TYPE, A.[SALE_INVOICENO] AS INVOICENO, " +
                        " CONVERT(VARCHAR(11), A.[SALE_INVOICEDATE],106) AS INVOICEDATE from [ax].[ACXPURCHINVRECIEPTHEADER] A where A.[SITE_Code]='" + Session["SiteCode"].ToString() + "' " +
                        "and A.[DATAAREAID]='" + Session["DATAAREAID"].ToString() + "' and A.PURCH_RECIEPTNO='" + drpRecieptNo.SelectedItem.Text + "' ";


                dt = new DataTable();
                dt = obj.GetData(query);
                if (dt.Rows.Count > 0)
                {
                    txtReceiptDate.Text = dt.Rows[0]["DOCUMENT_DATE"].ToString();

                    //txtInvoiceNo.Text = dt.Rows[0]["INVOICENO"].ToString();
                    txtInvoiceDate.Text = dt.Rows[0]["INVOICEDATE"].ToString();
                    decimal materialValue = Convert.ToDecimal(dt.Rows[0]["MATERIAL_VALUE"].ToString());
                    txtReceiptValue.Text    = (Math.Round(materialValue, 2)).ToString();
                    txtIndentNo.Text        = dt.Rows[0]["PURCH_INDENTNO"].ToString();
                    txtIndentDate.Text      = dt.Rows[0]["PURCH_INDENTDATE"].ToString();
                    txtTransporterName.Text = dt.Rows[0]["TRANSPORTER_CODE"].ToString();
                    txtVehicleNumber.Text   = dt.Rows[0]["VEHICAL_NO"].ToString();
                    txtVehicleType.Text     = dt.Rows[0]["VEHICAL_TYPE"].ToString();
                    //txtDriverNumber.Text = dt.Rows[0]["PURCH_INDENTDATE"].ToString();
                }
                //================Fill Line Item=============

                ShowRecords(drpRecieptNo.SelectedItem.Text);
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
        //protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    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,NAME from [ax].[INVENTSITE] where STATECODE = '" + ddlState.SelectedItem.Value + "'";
        //        ddlSiteId.Items.Add("All...");
        //        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 uniqueCols = dt.DefaultView.ToTable(true, "Distributor", "distributor Name");

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

        //            baseObj.BindToDropDown(ddlSiteId, sqlstr1, "Name", "Code");
        //        }
        //    }


        //}

        protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
        {
            string statesel = "";

            foreach (System.Web.UI.WebControls.ListItem litem1 in ddlState.Items)
            {
                if (litem1.Selected)
                {
                    if (statesel.Length == 0)
                    {
                        statesel = "'" + litem1.Value.ToString() + "'";
                    }
                    else
                    {
                        statesel += ",'" + litem1.Value.ToString() + "'";
                    }
                }
            }
            if (ddlState.SelectedValue == string.Empty)
            {
                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");
                ddlSiteId.DataSource     = distinctValues;
                ddlSiteId.DataTextField  = "DistributorName";
                ddlSiteId.DataValueField = "distributor";
                ddlSiteId.DataBind();
                //ddlSiteId.Items.Add("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,NAME from [ax].[INVENTSITE] where STATECODE in (" + statesel + ")";
                    //ddlSiteId.Items.Add("All...");
                    // ddlSiteId.Items.Insert(0, "All...");
                    //baseObj.BindToDropDown(ddlSiteId, sqlstr1, "Name", "Code");
                    DataTable dt = baseObj.GetData(sqlstr1);
                    ddlSiteId.DataSource     = dt;
                    ddlSiteId.DataTextField  = "Name";
                    ddlSiteId.DataValueField = "Code";
                    ddlSiteId.DataBind();
                }
                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);
                        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 in (" + statesel + ")";
                        DataTable uniqueCols = dt.DefaultView.ToTable(true, "Distributor", "DistributorName");

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

                        //baseObj.BindToDropDown(ddlSiteId, sqlstr1, "Name", "Code");
                        DataTable dt = baseObj.GetData(sqlstr1);
                        ddlSiteId.DataSource     = dt;
                        ddlSiteId.DataTextField  = "Name";
                        ddlSiteId.DataValueField = "Code";
                        ddlSiteId.DataBind();
                    }
                }
            }
        }