protected void fillSiteAndState()
        {
            try
            {
                string sqlstr           = "select * from ax.ACXSITEMENU where SITE_CODE ='" + Session["SiteCode"].ToString() + "'";
                object objcheckSitecode = obj.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...");
                    obj.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";
                    obj.BindToDropDown(ddlState, sqlstr1, "StateName", "StateCode");
                    obj.BindToDropDown(ddlSiteId, sqlstr1, "SiteName", "SiteId");
                }
            }
            catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); }
        }
        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); }
        }
Beispiel #3
0
        protected void FillState()
        {
            string    sqlstr           = "select * from ax.ACXSITEMENU where SITE_CODE  IN (" + ucRoleFilters.GetCommaSepartedSiteId() + ")";
            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  IN (" + ucRoleFilters.GetCommaSepartedSiteId() + ")";
                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();
                }
                if (chkListSite.Items.Count > 1)
                {
                    chkListState.Items[0].Selected = true;
                    chkListSite.Items[0].Selected  = true;
                }
                FillCustomerGroup();
            }
        }
        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 <>''  ";
                ddlState.Items.Add("All...");
                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");
            }
        }
        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();
                chkListSite1.Items.Clear();
                string sqlstr11 = "Select Distinct I.StateCode Code,I.StateCode +' - '+LS.Name as 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();
            }
            else
            {
                chkListState.Items.Clear();
                chkListSite1.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();
                chkListSite1.DataSource     = dt;
                chkListSite1.DataTextField  = "SiteName";
                chkListSite1.DataValueField = "SiteId";
                chkListSite1.DataBind();
                if (chkListSite1.Items.Count > 0)
                {
                    chkListState.Items[0].Selected = true;
                    chkListSite1.Items[0].Selected = true;
                }
            }
        }
Beispiel #6
0
        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();
                if (ddlState.SelectedItem == null)
                {
                }
                else
                {
                    string sqlstr1 = @"Select Distinct SITEID as Code,SITEID+'-'+NAME 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 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");
                    ddlSiteId.DataSource     = uniqueCols;
                    ddlSiteId.DataTextField  = "Name";
                    ddlSiteId.DataValueField = "Distributor";
                    ddlSiteId.DataBind();
                    //ddlSiteId.Items.Add("All...");
                    ddlSiteId.Items.Insert(0, "All...");
                }
                else
                {
                    string sqlstr1 = @"Select Distinct SITEID as Code,SITEID+'-'+NAME Name from [ax].[INVENTSITE] where SITEID = '" + Session["SiteCode"].ToString() + "'";
                    //ddlSiteId.Items.Add("All...");
                    baseObj.BindToDropDown(ddlSiteId, sqlstr1, "Name", "Code");
                    ddlSiteId_SelectedIndexChanged(null, null);
                }
            }
        }
        protected void lstState_SelectedIndexChanged(object sender, EventArgs e)
        {
            string StateList = App_Code.Global.GetSelectState(ref lstState, true);

            string strSqlQuery = "", strCondition = "";

            lstSiteId.Items.Clear();
            strSqlQuery = @"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 ";
            if (Convert.ToString(Session["LOGINTYPE"]) == "3")
            {
                lstSiteId.Items.Clear();
                DataTable dt1                   = App_Code.Global.HierarchyDataTable(ref chkListHOS, ref chkListVP, ref chkListGM, ref chkListDGM, ref chkListRM, ref chkListZM, ref chkListASM, ref chkListEXECUTIVE);
                DataView  view                  = new DataView(dt1);
                DataTable distinctValues        = view.ToTable(true, "Distributor", "DistributorName");
                string    AllSitesFromHierarchy = "";
                foreach (DataRow row in distinctValues.Rows)
                {
                    if (AllSitesFromHierarchy == "")
                    {
                        AllSitesFromHierarchy += "'" + row["Distributor"].ToString() + "'";
                    }
                    else
                    {
                        AllSitesFromHierarchy += ",'" + row["Distributor"].ToString() + "'";
                    }
                }
                strCondition = " WHERE SITEID IN (" + AllSitesFromHierarchy + ")";
            }
            else
            {
                string sqlstr           = "select * from ax.ACXSITEMENU where SITE_CODE ='" + Session["SiteCode"].ToString() + "'";
                object objcheckSitecode = baseObj.GetScalarValue(sqlstr);
                if (objcheckSitecode != null)
                {
                }
                else
                {
                    strCondition = " WHERE SITEID='" + Session["SiteCode"].ToString() + "'";
                }
            }
            if (StateList != "")
            {
                strCondition += (strCondition == "" ? " WHERE STATECODE in (" + StateList + ")" : " AND STATECODE in (" + StateList + ")");
            }

            strCondition += " Order by SiteName";
            strSqlQuery  += StateList = strCondition;

            DataTable dt = baseObj.GetData(strSqlQuery);

            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;
                }
                lstSiteId_SelectedIndexChanged(sender, e);
            }
        }
        protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
        {
            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 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 + ") 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 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() + "'";
                        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;
                }
            }
            Session["SalesData"] = App_Code.Global.HierarchyDataTable(ref chkListHOS, ref chkListVP, ref chkListGM, ref chkListDGM, ref chkListRM, ref chkListZM, ref chkListASM, ref chkListEXECUTIVE);
        }
Beispiel #9
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            lblMessage.Text = string.Empty;
            //=============Validation=================
            foreach (GridViewRow grv in gvDetails.Rows)
            {
                HiddenField lblProduct = (HiddenField)grv.FindControl("HiddenValueItemCode");
                if (DrpItemDescription.SelectedItem.Value == lblProduct.Value)
                {
                    string message = "alert('" + DrpItemDescription.SelectedItem.Text + " is already exists in the list .Please Select Another Product !!');";
                    ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true);


                    return;
                }
            }

            //=================================
            //==============================================



            if (drpItemCode.Text == "Select..." || drpItemCode.Text == "")
            {
                string message = "alert('Select Item Sub Group First !');";
                ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true);
                drpItemCode.Focus();
                return;
            }
            if (drpItemCategory.Text == string.Empty || drpItemCategory.Text == "Select...")
            {
                string message = "alert('Select Item Group First !');";
                ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true);
                drpItemCategory.Focus();
                return;
            }

            string strQuery    = "select isnull(sum(TransQty),0) from [ax].[ACXINVENTTRANS] where ProductCode='" + DrpItemDescription.SelectedItem.Value + "' and SiteCode='" + Session["SiteCode"] + "' and DocumentType='9'";
            string strTransQty = obj.GetScalarValue(strQuery);

            if (Convert.ToDecimal(txtQTYPcs.Text) >= Convert.ToDecimal(strTransQty))
            {
                string message = "alert('" + DrpItemDescription.SelectedItem.Value + " is not available in stock.Enter Quantity below than " + Math.Round(Convert.ToDecimal(strTransQty), 2) + "!!');";
                ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true);
                txtQTYPcs.Focus();

                return;
            }
            if (txtQTYPcs.Text == string.Empty || txtQTYPcs.Text == "0")
            {
                string message = "alert(' Invalid Qty !');";
                ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true);

                return;
            }
            if (drpPSRName.Text == string.Empty || drpPSRName.Text == "Select...")
            {
                string message = "alert('Select PSR Name First !');";
                ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", message, true);
                drpItemCategory.Focus();
                return;
            }
            DataTable dt = new DataTable();

            dt = Session["ItemTable"] as DataTable;
            if (Session["LineItem"] == null)
            {
                DataColumn column = new DataColumn();
                column.DataType          = System.Type.GetType("System.Int32");
                column.AutoIncrement     = true;
                column.AutoIncrementSeed = 1;
                column.AutoIncrementStep = 1;
                column.ColumnName        = "Sr_No";
                //-----------------------------------------------------------//

                dtLineItems = new DataTable("LineItemTable");
                dtLineItems.Columns.Add(column);

                dtLineItems.Columns.Add("Item_Category", typeof(string));
                dtLineItems.Columns.Add("Item_SubCategory", typeof(string));
                dtLineItems.Columns.Add("Item_Code", typeof(string));
                dtLineItems.Columns.Add("Item_Name", typeof(string));
                dtLineItems.Columns.Add("QTY", typeof(string));
            }
            else
            {
                dtLineItems = (DataTable)Session["LineItem"];
            }
            DataRow row;

            row = dtLineItems.NewRow();

            row["Item_Category"]    = drpItemCategory.Text;
            row["Item_SubCategory"] = drpItemCode.SelectedItem.Value;
            row["Item_Code"]        = DrpItemDescription.SelectedItem.Value;
            row["Item_Name"]        = DrpItemDescription.SelectedItem.Text;
            row["QTY"] = txtQTYPcs.Text;

            dtLineItems.Rows.Add(row);

            Session["LineItem"] = dtLineItems;
            dt = dtLineItems;;

            if (dt.Rows.Count > 0)
            {
                gvDetails.DataSource = dt;
                gvDetails.DataBind();
            }
            else
            {
                gvDetails.DataSource = dt;
                gvDetails.DataBind();
            }



            btnAdd.Enabled = true;
            btnAdd.Attributes.Add("onclick", " this.disabled = false; " + ClientScript.GetPostBackEventReference(btnAdd, null) + ";");
            drpItemCategory.Focus();
        }