Example #1
0
        protected void FillBusinessUnitsForLoginType3()
        {
            DataTable dt    = new DataTable();
            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 ('" + GetStringValueCommaSeparted(ucRoleFilters.GetCommaSepartedSiteId()) + "')";

            dt = new DataTable();

            dt = baseObj.GetData(query);
            ChkBunt.Items.Clear();
            ChkBunt.DataSource     = dt;
            ChkBunt.DataTextField  = "bu_desc";
            ChkBunt.DataValueField = "bu_code";
            ChkBunt.DataBind();
        }
 protected void BindGridview()
 {
     try
     {
         string query;
         query = "EXEC [dbo].[ACX_GETPENDINGSO] '" + Session["SiteCode"].ToString() + "'";
         CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
         DataTable dt = new DataTable();
         dt = obj.GetData(query);
         if (dt.Rows.Count > 0)
         {
             dt = SortDataView(dt);
             gvHeader.DataSource = dt;
             gvHeader.DataBind();
         }
         else
         {
             dt.Rows.Add(dt.NewRow());
             gvHeader.DataSource = dt;
             gvHeader.DataBind();
             int columncount = gvHeader.Rows[0].Cells.Count;
             gvHeader.Rows[0].Cells.Clear();
             gvHeader.Rows[0].Cells.Add(new TableCell());
             gvHeader.Rows[0].Cells[0].ColumnSpan = columncount;
             gvHeader.Rows[0].Cells[0].Text       = "No Records Found";
         }
         Session["SaleOrderSearch"] = dt;
     }
     catch (Exception ex)
     {
         ErrorSignal.FromCurrentContext().Raise(ex);
     }
 }
        protected void BindGridview(string param)
        {
            try
            {
                string query;

                query = @"Select A.INVOICE_NO,A.INVOIC_DATE,A.INVOICE_VALUE,A.SITEID as DistCode,DistName = (select Name from [ax].[INVENTSITE] where SITEID =  A.SITEID)
                        from [ax].[ACXSALEINVOICEHEADER] A left Join  [ax].[ACXPURCHINVRECIEPTHEADER] B on B.Site_Code=A.Customer_Code 
                        and B.Supplier_Code=A.SiteID and B.Sale_InvoiceNo=A.Invoice_NO inner join [ax].[ACXUSERMASTER] C on C.Site_Code = A.CUSTOMER_CODE
                        Where  B.Sale_InvoiceNo is null and A.Trantype<>2 and  A.INVOIC_DATE >= C.PurchaseStartDate  and 
                        (SELECT ISNULL(SUM(BOX),0) FROM [ax].[ACXSALEINVOICELINE] SL WHERE SL.SITEID=A.SITEID AND SL.INVOICE_NO=A.INVOICE_NO)
	                    >(SELECT ISNULL(SUM(BOX),0) FROM [ax].[ACXSALEINVOICELINE] SL JOIN AX.ACXSALEINVOICEHEADER SH ON SH.SITEID=SL.SITEID 
                        AND SH.INVOICE_NO=SL.INVOICE_NO AND SL.SITEID=A.SITEID AND SH.SO_NO=A.INVOICE_NO AND SL.TRANTYPE=2)and A.Customer_Code='" + Session["SiteCode"].ToString() + param + "' Order by A.SITEID,A.INVOICE_NO ";
                CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
                DataTable dt = new DataTable();
                dt = obj.GetData(query);
                if (dt.Rows.Count > 0)
                {
                    gvHeader.DataSource = dt;
                    gvHeader.DataBind();
                }
                else
                {
                    gvHeader.DataSource = null;
                    gvHeader.DataBind();
                }
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
Example #4
0
        private void GetPSRBeat()
        {
            try
            {
                CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();



                string query = " Select A.PSRCode,C.PSR_Name as PSRName,A.BeatCode,A.BeatName,d.Discription as BeatDayDesc " +
                               " from AX.ACXPSRBEATMASTER A " +
                               " inner JOIN AX.ACXPSRSITELinkingMaster B ON A.PSRCode = B.PSRCode and A.Site_code = B.Site_Code  " +
                               " inner Join ax.[ACXPSRMaster] c on A.PSRCode = C.PSR_Code " +
                               " left Join ax.ACXWeekMaster d on d.DayCode=A.BeatDay " +
                               " where B.Site_Code='" + Session["SiteCode"].ToString() + "'" +
                               " order By C.PSR_Name,A.BeatName ";


                DataTable dt = obj.GetData(query);
                if (dt.Rows.Count > 0)
                {
                    gvDetails.DataSource = dt;
                    gvDetails.DataBind();
                }
            }
            catch (Exception ex) { ErrorSignal.FromCurrentContext().Raise(ex); }
        }
Example #5
0
        private void GetPSRCustomer()
        {
            try
            {
                CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();

                string query = " Select A.CustomerCode,A.CustomerName ," +
                               " A.PSRCode,PSRName=(select C.PSR_Name from [ax].[ACXPSRMaster] C where C.PSR_Code=A.PSRCode )," +
                               " A.BeatCode,B.BeatName,B.BeatDay,BeatDayDesc=(Select F.Discription from ax.ACXWeekMaster F where F.DayCode=B.BeatDay)  " +
                               " from [ax].[ACXPSRCUSTLinkingMaster] A   " +
                               " Left Join [ax].[ACXPSRBeatMaster] B on A.BeatCode=B.BeatCode and A.PSRCode=b.PSRCode AND A.SITE_CODE = B.SITE_CODE " +
                               " Left Join [ax].[ACXCUSTMASTER] C on A.CustomerCode=C.Customer_Code  AND A.SITE_CODE = C.SITE_CODE " +
                               " where A.Site_Code='" + Session["SiteCode"].ToString() + "' and C.Blocked = 0 order by PSRName,BeatName,A.CustomerName";

                DataTable dt = obj.GetData(query);
                if (dt.Rows.Count > 0)
                {
                    gvDetails.DataSource = dt;
                    gvDetails.DataBind();
                }
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
Example #6
0
        private void LoadSiteIDDetails()
        {
            CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();

            string query = "Select NAME , ACXADDRESS1 + ACXADDRESS2 + ',' + ACXCITY AS SITEADDRESS from ax.inventsite where SITEID='" + Session["SiteCode"] + "'";

            System.Data.DataTable dt = obj.GetData(query);
            if (dt.Rows.Count > 0)
            {
                lblAddress.Text = dt.Rows[0]["SITEADDRESS"].ToString();
            }
        }
        protected void lnkbtn_Click(object sender, EventArgs e)
        {
            try
            {
                GridViewRow gvrow = (GridViewRow)(((LinkButton)sender)).NamingContainer;
                LinkButton  lnk   = sender as LinkButton;
                Session["Lndentno"] = lnk.Text;
                DataTable dt = new DataTable();
                string    query;
                //query = "select A.Indent_No, A.Line_No,A.Product_Group,A.Product_Code," +
                //        "Product_Name=(Select B.Product_Name from ax.AcxProductMaster B where B.Product_Code=A.Product_Code and " +
                //        "B.Product_GRoup=A.Product_Group)," +
                //        "cast(A.Box as decimal(10,2)) Box ,cast(A.Crates as decimal(10,2)) Crates ,cast(A.Ltr as decimal(10,2)) Ltr " +
                //        "from ax.ACXPurchIndentLine A Where A.Indent_No='" + lnk.Text + "' and A.SITEID='" + Session["SiteCode"].ToString() + "' order by A.Line_no";

                query = "select A.Indent_No, A.Line_No,A.Product_Group,A.Product_Code," +
                        "Product_Name=(Select B.Product_Name from ax.INVENTTABLE B where B.Itemid=A.Product_Code and " +
                        "B.Product_GRoup=A.Product_Group)," +
                        "cast(A.Box as decimal(10,2)) Box ,cast(A.Crates as decimal(10,2)) Crates ,cast(A.Ltr as decimal(10,2)) Ltr " +
                        "from ax.ACXPurchIndentLine A Where A.Indent_No='" + lnk.Text + "' and A.SITEID='" + Session["SiteCode"].ToString() + "' order by A.Line_no";

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

                dt = obj.GetData(query);
                if (dt.Rows.Count > 0)
                {
                    gvLineDetails.DataSource = dt;
                    gvLineDetails.DataBind();
                }
                else
                {
                    dt.Rows.Add(dt.NewRow());
                    gvLineDetails.DataSource = dt;
                    gvLineDetails.DataBind();
                    int columncount = gvHeader.Rows[0].Cells.Count;
                    gvLineDetails.Rows[0].Cells.Clear();
                    gvLineDetails.Rows[0].Cells.Add(new TableCell());
                    gvLineDetails.Rows[0].Cells[0].ColumnSpan = columncount;
                }
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
            finally
            {
            }
        }
        protected void SONo_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                GridViewRow gvrow = (GridViewRow)(((LinkButton)sender)).NamingContainer;
                CheckBox    lnk   = sender as CheckBox;
                DataTable   dt    = new DataTable();
                string      query = "Select B.SO_NO,CONVERT(VARCHAR(11),B.SO_Date,106) as SO_Date," +
                                    "Customer_Group=(select C.CustGroup_Name from ax.ACXCUSTGROUPMASTER C where C.CustGroup_Code=D.Cust_Group)," +
                                    "Concat(D.Customer_Code,'-',D.Customer_Name) as customer," +
                                    "E.Product_Group, E.ItemId+'-'+E.Product_Name as Product," +
                                    "cast(A.BOX as decimal(10,2)) as BOX,cast(A.Crates as decimal(10,2)) as Crates,cast(A.Ltr as decimal(10,2)) as Ltr " +
                                    " from ax.ACXLOADSHEETLINE A" +
                                    " left join ax.ACXLOADSHEETHEADER B on A.LoadSheet_No=B.LoadSheet_No" +
                                    " left join ax.Acxcustmaster D on D.Customer_Code=B.Customer_Code" +
                                    // " left Join ax.ACXProductMaster E on A.Product_COde=E.Product_Code" +
                                    " left Join ax.InventTable E on A.Product_COde=E.ItemId" +
                                    " Where B.SO_NO='" + lnk.Text + "' and A.SHITEID='" + Session["SiteCode"].ToString() + "'" +
                                    " Order By A.Line_No";

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

                dt = obj.GetData(query);
                if (dt.Rows.Count > 0)
                {
                    gvLineDetails.DataSource = dt;
                    gvLineDetails.DataBind();
                }
                else
                {
                    dt.Rows.Add(dt.NewRow());
                    gvLineDetails.DataSource = dt;
                    gvLineDetails.DataBind();
                    int columncount = gvHeader.Rows[0].Cells.Count;
                    gvLineDetails.Rows[0].Cells.Clear();
                    gvLineDetails.Rows[0].Cells.Add(new TableCell());
                    gvLineDetails.Rows[0].Cells[0].ColumnSpan = columncount;
                }
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
            finally
            {
            }
        }
        public void BindLineItem()
        {
            try

            {
                DataTable dt = new DataTable();

                string query = "select A.SO_NO,CONVERT(VARCHAR(11),B.[SO_DATE],106) as SO_Date," +
                               "Customer_Group=(select C.CustGroup_Name from ax.ACXCUSTGROUPMASTER C where C.CustGroup_Code=D.Cust_Group),Concat (D.Customer_Code,'-',D.Customer_Name) as customer," +
                               "Concat(D.Customer_Code,'-',D.Customer_Name) as customer," +
                               "E.Product_Group, E.ItemId+'-'+E.Product_Name as Product,cast(A.BOX as decimal(10,2)) as BOX,cast(A.Crates as decimal(10,2)) as Crates,cast(A.Ltr as decimal(10,2)) as Ltr" +
                               " from ax.ACXSALESLINE A left join [ax].[ACXSALESHEADER] B on A.SO_NO=B.SO_NO left join ax.Acxcustmaster D on D.Customer_Code=B.Customer_Code left Join ax.InventTable E on A.Product_COde=E.ItemId" +
                               " Where B.SO_NO='" + Session["SO_NO"].ToString() + "' and A.SITEID='" + Session["SiteCode"].ToString() + "'" +
                               " Order By A.Line_No";



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

                dt = obj.GetData(query);
                if (dt.Rows.Count > 0)
                {
                    gvLineDetails.DataSource = dt;
                    gvLineDetails.DataBind();
                }
                else
                {
                    dt.Rows.Add(dt.NewRow());
                    gvLineDetails.DataSource = dt;
                    gvLineDetails.DataBind();
                    int columncount = gvLineDetails.Rows[0].Cells.Count;
                    gvLineDetails.Rows[0].Cells.Clear();
                    gvLineDetails.Rows[0].Cells.Add(new TableCell());
                    gvLineDetails.Rows[0].Cells[0].ColumnSpan = columncount;
                }
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
            finally
            {
            }
        }
        protected void BindGridview()
        {
            try
            {
                string query;
                query = "Select A.Indent_NO,CONVERT(VARCHAR(11),A.Indent_Date,106) as Indent_Date ,coalesce(CONVERT(VARCHAR(11),Required_Date,106),'') as Required_Date," +
                        // "SALEOFFICE_CODE=(select B.SALEOFFICE_CODE from ax.ACXSITEMASTER B where B.SiteId=A.SiteId )," +
                        "SALEOFFICE_CODE=(select B.ACXPLANTCODE from [ax].[INVENTSITE] B where B.SiteId=A.SiteId )," +
                        //"SALEOFFICE_NAME=(select B.SALEOFFICE_NAME from ax.ACXSITEMASTER B where B.SiteId=A.SiteId ),"+
                        "SALEOFFICE_NAME=(select B.ACXPLANTNAME from [ax].[INVENTSITE] B where B.SiteId=A.SiteId )," +
                        "Box=(Select cast(sum(C.BOX) as decimal(10,2)) BOX   from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId )," +
                        "Crates=(Select cast(sum(C.Crates) as decimal(10,2)) Crates from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId )," +
                        "Ltr=(Select cast(sum(C.Ltr) as decimal(10,2)) Ltr  from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId )," +
                        "A.So_No, A.Invoice_No ," +
                        " case A.STATUS when  1 then 'Confirm' when 0  then 'Pending' end as Confirm " +
                        "from ax.ACXPURCHINDENTHEADER A where A.indent_No!='' and [Siteid]='" + Session["SiteCode"].ToString() + "' order by A.Indent_Date desc";

                CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
                DataTable dt = new DataTable();
                dt = obj.GetData(query);
                if (dt.Rows.Count > 0)
                {
                    gvHeader.DataSource = dt;
                    gvHeader.DataBind();
                }
                else
                {
                    dt.Rows.Add(dt.NewRow());
                    gvHeader.DataSource = dt;
                    gvHeader.DataBind();
                    int columncount = gvHeader.Rows[0].Cells.Count;
                    gvHeader.Rows[0].Cells.Clear();
                    gvHeader.Rows[0].Cells.Add(new TableCell());
                    gvHeader.Rows[0].Cells[0].ColumnSpan = columncount;
                    gvHeader.Rows[0].Cells[0].Text       = "No Records Found";
                }
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
Example #11
0
        public void BindNewLine()
        {
            try
            {
                DataTable dt = new DataTable();
                string    query;
                query = "select A.Indent_No, A.Line_No,A.Product_Group,A.Product_Code," +
                        "Product_Name=(Select B.Product_Name from ax.AcxProductMaster B where B.Product_Code=A.Product_Code and " +
                        "B.Product_GRoup=A.Product_Group)," +
                        "cast(A.Box as decimal(10,2)) Box ,cast(A.Crates as decimal(10,2)) Crates ,cast(A.Ltr as decimal(10,2)) Ltr " +
                        "from ax.ACXPurchIndentLine A Where A.Indent_No='" + Session["IndentNo"].ToString() + "' and A.SITEID='" + Session["SiteCode"].ToString() + "' order by A.Line_no";

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

                dt = obj.GetData(query);
                if (dt.Rows.Count > 0)
                {
                    gvLineDetails.DataSource = dt;
                    gvLineDetails.DataBind();
                }
                else
                {
                    dt.Rows.Add(dt.NewRow());
                    gvLineDetails.DataSource = dt;
                    gvLineDetails.DataBind();
                    int columncount = gvHeader.Rows[0].Cells.Count;
                    gvLineDetails.Rows[0].Cells.Clear();
                    gvLineDetails.Rows[0].Cells.Add(new TableCell());
                    gvLineDetails.Rows[0].Cells[0].ColumnSpan = columncount;
                }
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
            finally
            {
            }
        }
        private void GetPSRDistributorLinking()
        {
            try
            {
                CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();


                string query = " Select A.Site_Code,Site_Name=(select B.Name from [ax].[INVENTSITE] B where B.SITEID=A.Site_Code)," +
                               " A.PSRCode,PSRName=(select C.PSR_Name from [ax].[ACXPSRMaster] C where C.PSR_Code=A.PSRCode)," +
                               " CONVERT(VARCHAR(11),A.[FromDate],106) as [FromDate],CONVERT(VARCHAR(11),A.[TODate],106) as [TODate]" +
                               " from [ax].[ACXPSRSITELinkingMaster] A where A.Site_Code='" + Session["SiteCode"].ToString() + "' and A.Blocked=0 Order By PSRName,A.[FromDate] Desc";

                DataTable dt = obj.GetData(query);
                if (dt.Rows.Count > 0)
                {
                    gvDetails.DataSource = dt;
                    gvDetails.DataBind();
                }
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
Example #13
0
        protected void checkAll_CheckedChanged(object sender, EventArgs e)
        {
            string    strSONO = string.Empty;
            DataTable dt      = new DataTable();

            foreach (GridViewRow row in gvDetails.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    CheckBox chkRow = (row.Cells[0].FindControl("chkStatus") as CheckBox);
                    if (chkRow.Checked)
                    {
                        //strSONO += "'" + chkRow.Text + "',";                 //getting all So_No those are checked by User
                        strSONO += "" + chkRow.Text + ",";
                    }
                }
            }
            //==============For Warehouse Loacion 11-5-16===========
            CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
            string TransLocation = "";

            string query1 = "select MainWarehouse from ax.inventsite where siteid='" + Session["SiteCode"].ToString() + "'";

            dt = new DataTable();
            dt = obj.GetData(query1);
            if (dt.Rows.Count > 0)
            {
                TransLocation = dt.Rows[0]["MainWarehouse"].ToString();
            }
            //====================================
            if (strSONO != string.Empty)
            {
                strSONO = strSONO.Remove(strSONO.Length - 1);

                //==============11-5-16========
                //string strSaleLine = "Select AP.PRODUCT_GROUP,AL.PRODUCT_CODE,AP.PRODUCT_NAME,Sum(AL.CRATES) as CRATES,Sum(AL.BOX) AS  BOX,Sum(AL.LTR) AS LTR " +
                //                      ",StockBox=(Select coalesce(cast(sum(F.TransQty) as decimal(10,2)),0) as TransQty from [ax].[ACXINVENTTRANS] F where F.[SiteCode]=AL.SITEID and F.[ProductCode]=AL.Product_COde and F.[TransLocation]='" + TransLocation + "')" +
                //                      ",StockLtr =(Select coalesce(cast((sum(F.TransQty)*AP.Product_PackSize*AP.LTR)/1000 as decimal(10,2)),0) as TransQty from [ax].[ACXINVENTTRANS] F where F.[SiteCode]=AL.SITEID and F.[ProductCode]=AL.Product_COde and F.[TransLocation]='" + TransLocation + "')" +
                //                      " from [ax].[ACXSALESLINE] AL Inner Join [ax].[InventTable] AP on AL.PRODUCT_CODE = AP.ItemId " +
                //                      " where SO_No In (" + strSONO + ") and  AL.SiteId='" + Session["SiteCode"].ToString() + "' group by AL.SITEID,AP.PRODUCT_GROUP,AL.PRODUCT_CODE,AP.PRODUCT_NAME,AP.Product_PackSize,AP.LTR";

                string strSaleLine = "EXEC ACX_GETLOADSHEET '" + Session["SiteCode"].ToString() + "','" + TransLocation + "','" + strSONO + "'";

                dt = baseObj.GetData(strSaleLine);
                if (dt.Rows.Count > 0)
                {
                    GridView2.Visible    = true;
                    GridView2.DataSource = dt;
                    GridView2.DataBind();
                }
                else
                {
                    dt = null;
                    GridView2.Visible    = false;
                    GridView2.DataSource = dt;
                    GridView2.DataBind();
                }
            }
            else
            {
                dt = null;
                GridView2.DataSource = dt;
                GridView2.DataBind();
            }
            //UppnalegridDetails.Update();
        }
Example #14
0
        protected void btn2_Click(object sender, EventArgs e)
        {
            if (txtSearch.Text != "" || ddlSerch.SelectedItem.Text == "All")
            {
                gvHeader.DataSource = null;
                gvHeader.DataBind();
                gvLineDetails.DataSource = null;
                gvLineDetails.DataBind();

                if (ddlSerch.SelectedItem.Text == "All")
                {
                    BindGridview();
                }
                else
                {
                    string search = "";
                    search = "%" + txtSearch.Text + "%";
                    try

                    {
                        string query;
                        //string query = "Select A.Indent_NO,CONVERT(VARCHAR(11),A.Indent_Date,106) as Indent_Date ,coalesce(CONVERT(VARCHAR(11),Required_Date,106),'') as Required_Date," +
                        //    //"SALEOFFICE_CODE=(select B.SALEOFFICE_CODE from ax.ACXSITEMASTER B where B.SiteId=A.SiteId )," +
                        //"SALEOFFICE_CODE=(select B.ACXPLANTCODE from [ax].[INVENTSITE] B where B.SiteId=A.SiteId )," +
                        //    //"SALEOFFICE_NAME=(select B.SALEOFFICE_NAME from ax.ACXSITEMASTER B where B.SiteId=A.SiteId )," +
                        //"SALEOFFICE_NAME=(select B.ACXPLANTNAME from [ax].[INVENTSITE] B where B.SiteId=A.SiteId )," +
                        //"Box=(Select cast(sum(C.BOX) as decimal(10,2)) BOX   from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId )," +
                        //"Crates=(Select cast(sum(C.Crates) as decimal(10,2)) Crates from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId )," +
                        //"Ltr=(Select cast(sum(C.Ltr) as decimal(10,2)) Ltr  from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId )," +
                        //" A.So_No, A.Invoice_No ," +
                        //" case A.STATUS when  1 then 'Confirm' when 0  then 'Pending' end as Confirm " +
                        //"from ax.ACXPURCHINDENTHEADER A where A.indent_No!='' and [Siteid]='" + Session["SiteCode"].ToString() + "' and A." + ddlSerch.SelectedItem.Value + " like '" + search + "'  order by A.Indent_No";

                        string searchitem = ddlSerch.SelectedItem.Value;
                        if (searchitem == "Customer_Code")
                        {
                            searchitem = "SiteID";
                            query      = @"Select A.Indent_NO,CONVERT(VARCHAR(11),A.Indent_Date,106) as Indent_Date ,coalesce(CONVERT(VARCHAR(11),A.Required_Date,106),'') as Required_Date,
                            DISTRIBUTOR_CODE=(select B.SiteId from [ax].[INVENTSITE] B where B.SiteId=A.SiteId ),
                            DISTRIBUTOR_NAME=(select B.NAME from [ax].[INVENTSITE] B where B.SiteId=A.SiteId),
                            Box=(Select cast(sum(C.BOX) as decimal(10,2)) BOX   from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId ),
                            Crates=(Select cast(sum(C.Crates) as decimal(10,2)) Crates from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId ),
                            Ltr=(Select cast(sum(C.Ltr) as decimal(10,2)) Ltr  from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId ),
                            A.So_No, A.Invoice_No , case A.STATUS when  1 then 'Confirm' when 0  then 'Pending' end as Confirm 
                            from ax.ACXPURCHINDENTHEADER A  where A.indent_No!='' and 
                            A.[ACXPLANTNAME]='" + Session["SiteCode"].ToString() + "' and A." + searchitem + " like '" + search + "' " +
                                         " and A.STATUS =1 order by Indent_Date Desc,A.Indent_No desc ";
                        }
                        else if (searchitem == "Customer_Name")
                        {
                            query = @"Select A.Indent_NO,CONVERT(VARCHAR(11),A.Indent_Date,106) as Indent_Date ,coalesce(CONVERT(VARCHAR(11),A.Required_Date,106),'') as Required_Date,
                            DISTRIBUTOR_CODE=(select B.SiteId from [ax].[INVENTSITE] B where B.SiteId=A.SiteId ),
                            DISTRIBUTOR_NAME=(select B.NAME from [ax].[INVENTSITE] B where B.SiteId=A.SiteId),
                            Box=(Select cast(sum(C.BOX) as decimal(10,2)) BOX   from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId ),
                            Crates=(Select cast(sum(C.Crates) as decimal(10,2)) Crates from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId ),
                            Ltr=(Select cast(sum(C.Ltr) as decimal(10,2)) Ltr  from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId ),
                            A.So_No, A.Invoice_No , case A.STATUS when  1 then 'Confirm' when 0  then 'Pending' end as Confirm 
                            from ax.ACXPURCHINDENTHEADER A Inner Join [ax].[INVENTSITE] B on B.SiteId=A.SiteId  where A.indent_No!='' and 
                            A.[ACXPLANTNAME]='" + Session["SiteCode"].ToString() + "' and B.NAME like '" + search + "' " +
                                    " and A.STATUS =1 order by Indent_Date Desc,A.Indent_No desc ";
                        }
                        else
                        {
                            query = @"Select A.Indent_NO,CONVERT(VARCHAR(11),A.Indent_Date,106) as Indent_Date ,coalesce(CONVERT(VARCHAR(11),A.Required_Date,106),'') as Required_Date,
                            DISTRIBUTOR_CODE=(select B.SiteId from [ax].[INVENTSITE] B where B.SiteId=A.SiteId ),
                            DISTRIBUTOR_NAME=(select B.NAME from [ax].[INVENTSITE] B where B.SiteId=A.SiteId),
                            Box=(Select cast(sum(C.BOX) as decimal(10,2)) BOX   from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId ),
                            Crates=(Select cast(sum(C.Crates) as decimal(10,2)) Crates from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId ),
                            Ltr=(Select cast(sum(C.Ltr) as decimal(10,2)) Ltr  from ax.ACXPURCHINDENTLINE C where C.Indent_No=A.Indent_No and A.SiteId=C.SiteId ),
                            A.So_No, A.Invoice_No , case A.STATUS when  1 then 'Confirm' when 0  then 'Pending' end as Confirm 
                            from ax.ACXPURCHINDENTHEADER A  where A.indent_No!='' and 
                            A.[ACXPLANTNAME]='" + Session["SiteCode"].ToString() + "' and A." + searchitem + " like '" + search + "' " +
                                    " and A.STATUS =1 order by Indent_Date Desc,A.Indent_No desc ";
                        }


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

                        dt = obj.GetData(query);
                        if (dt.Rows.Count > 0)
                        {
                            gvHeader.DataSource = dt;
                            gvHeader.DataBind();
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "alerts", "javascript:alert('Record Not Found..')", true);
                        }
                        //===============================================
                        //  dt.Clear();
                        //  search = txtSearch.Text;
                        //  // query = "select A.Indent_No, A.Line_No,A.Product_Group,A.Product_Code," +
                        //  //"Product_Name=(Select B.Product_Name from ax.AcxProductMaster B where B.Product_Code=A.Product_Code and " +
                        //  //"B.Product_GRoup=A.Product_Group)," +
                        //  //"cast(A.Box as decimal(10,2)) Box ,cast(A.Crates as decimal(10,2)) Crates ,cast(A.Ltr as decimal(10,2)) Ltr " +
                        //  //"from ax.ACXPurchIndentLine A Where A." + ddlSerch.SelectedItem.Value + "='" + search + "' and A.SITEID='" + Session["SiteCode"].ToString() + "' order by A.Line_no";

                        //  query = "select A.Indent_No, A.Line_No,A.Product_Group,A.Product_Code," +
                        //"Product_Name=(Select B.Product_Name from ax.INVENTTABLE B where B.Itemid=A.Product_Code and " +
                        //"B.Product_GRoup=A.Product_Group)," +
                        //"cast(A.Box as decimal(10,2)) Box ,cast(A.Crates as decimal(10,2)) Crates ,cast(A.Ltr as decimal(10,2)) Ltr " +
                        //"from ax.ACXPurchIndentLine A Where A." + ddlSerch.SelectedItem.Value + "='" + search + "' and A.SITEID='" + Session["SiteCode"].ToString() + "' order by A.Line_no";


                        //  dt = obj.GetData(query);
                        //  if (dt.Rows.Count > 0)
                        //  {
                        //      gvLineDetails.DataSource = dt;
                        //      gvLineDetails.DataBind();
                        //  }
                        //  else
                        //  {
                        //      //ScriptManager.RegisterStartupScript(this, this.GetType(), "alerts", "javascript:alert('Record Not Found..')", true);
                        //  }
                    }
                    catch (Exception ex)
                    {
                        ErrorSignal.FromCurrentContext().Raise(ex);
                    }
                    finally
                    {
                    }
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alerts", "javascript:alert('Enter the text in serchbox..')", true);
            }
        }
        public void UpdateTransTable(string PostedDocumentNo, SqlTransaction trans, SqlConnection conn)
        {
            try
            {
                CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
                string TransLocation = "";
                string TransId       = string.Empty;

                string    query1 = "select MainWarehouse from ax.inventsite where siteid='" + Session["SiteCode"].ToString() + "'";
                DataTable dt     = new DataTable();
                dt = obj.GetData(query1);
                if (dt.Rows.Count > 0)
                {
                    TransLocation = dt.Rows[0]["MainWarehouse"].ToString();
                }

                string queryInsert = " Insert Into ax.acxinventTrans " +
                                     "([TransId],[SiteCode],[DATAAREAID],[RECID],[InventTransDate],[TransType],[DocumentType]," +
                                     "[DocumentNo],[DocumentDate],[ProductCode],[TransQty],[TransUOM],[TransLocation],[Referencedocumentno])" +
                                     " Values (@TransId,@SiteCode,@DATAAREAID,@RECID,@InventTransDate,@TransType,@DocumentType,@DocumentNo,@DocumentDate, " +
                                     " @ProductCode,@TransQty,@TransUOM,@TransLocation,@Referencedocumentno)";


                cmd                = new SqlCommand(queryInsert);
                cmd.Connection     = conn;
                cmd.Transaction    = transaction;
                cmd.CommandTimeout = 3600;
                cmd.CommandType    = CommandType.Text;

                string st = Session["SiteCode"].ToString();
                if (st.Length <= 6)
                {
                    TransId = st + System.DateTime.Now.ToString("yymmddhhmmss");
                }
                else
                {
                    TransId = st.Substring(st.Length - 6) + System.DateTime.Now.ToString("yymmddhhmmss");
                }

                for (int p = 0; p < GridPurchItems.Rows.Count; p++)
                {
                    string   Siteid          = Session["SiteCode"].ToString();
                    string   DATAAREAID      = Session["DATAAREAID"].ToString();
                    int      TransType       = 1;                               // Type 1 for Purchase Invoice Receipt
                    int      DocumentType    = 1;
                    string   DocumentNo      = PostedDocumentNo;
                    string   productNameCode = GridPurchItems.Rows[p].Cells[2].Text;
                    string[] str             = productNameCode.Split('-');
                    string   ProductCode     = str[0].ToString();
                    string   box             = GridPurchItems.Rows[p].Cells[4].Text;

                    decimal TransQty            = Convert.ToDecimal(box) * 1;
                    string  UOM                 = GridPurchItems.Rows[p].Cells[6].Text;
                    string  Referencedocumentno = PostedDocumentNo;
                    int     REcid               = p + 1;

                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@TransId", TransId);
                    cmd.Parameters.AddWithValue("@SiteCode", Siteid);
                    cmd.Parameters.AddWithValue("@DATAAREAID", DATAAREAID);
                    cmd.Parameters.AddWithValue("@RECID", p + 1);
                    cmd.Parameters.AddWithValue("@InventTransDate", DateTime.Now);
                    cmd.Parameters.AddWithValue("@TransType", TransType);
                    cmd.Parameters.AddWithValue("@DocumentType", DocumentType);
                    cmd.Parameters.AddWithValue("@DocumentNo", DocumentNo);
                    cmd.Parameters.AddWithValue("@DocumentDate", DateTime.Now);
                    cmd.Parameters.AddWithValue("@ProductCode", ProductCode);
                    cmd.Parameters.AddWithValue("@TransQty", TransQty);
                    cmd.Parameters.AddWithValue("@TransUOM", UOM);
                    cmd.Parameters.AddWithValue("@TransLocation", TransLocation);
                    cmd.Parameters.AddWithValue("@Referencedocumentno", Referencedocumentno);

                    int i = cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                LblMessage.Text = ex.Message.ToString();
                ErrorSignal.FromCurrentContext().Raise(ex);
            }

            #region old Code PROCEDURE ISSUE

            //try
            //{
            //    CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
            //    conn = obj.GetConnection();
            //    string TransLocation = "";
            //    string TransId = string.Empty;

            //    string query1 = "select MainWarehouse from ax.inventsite where siteid='" + Session["SiteCode"].ToString() + "'";
            //    DataTable dt = new DataTable();
            //    dt = obj.GetData(query1);
            //    if (dt.Rows.Count > 0)
            //    {
            //        TransLocation = dt.Rows[0]["MainWarehouse"].ToString();
            //    }

            //    string st = Session["SiteCode"].ToString();
            //    if (st.Length <= 6)
            //    {
            //        TransId = st + System.DateTime.Now.ToString("yymmddhhmmss");
            //    }
            //    else
            //    {
            //        TransId = st.Substring(st.Length - 6) + System.DateTime.Now.ToString("yymmddhhmmss");
            //    }


            //    cmd = new SqlCommand();
            //    cmd.Connection = conn;
            //    cmd.CommandTimeout = 100;
            //    cmd.CommandText = string.Empty;
            //    cmd.CommandType = CommandType.StoredProcedure;
            //    cmd.CommandText = "[ACX_PURCHINVC_UPDATEINVENTTRANS]";

            //    cmd.Parameters.Clear();

            //    string strSite = Session["SiteCode"].ToString();
            //    string strDAtaArea = Session["DATAAREAID"].ToString();

            //    cmd.Parameters.AddWithValue("@SITECODE", strSite);
            //    cmd.Parameters.AddWithValue("@DOCUMENTPURCHRECEIPTNUMBER", PostedDocumentNo);
            //    cmd.Parameters.AddWithValue("@DATAAREAID", strDAtaArea);
            //    cmd.Parameters.AddWithValue("@TRANSID", TransId);
            //    cmd.Parameters.AddWithValue("@WAREHOUSE", TransLocation);
            //    cmd.Parameters.AddWithValue("@TRANSTYPE", 1);

            //    int i = cmd.ExecuteNonQuery();
            //}
            //catch (Exception ex)
            //{
            //    LblMessage.Text = "Error: Inventory Update Issue - " + ex.Message.ToString();
            //}
            //finally
            //{
            //    if (conn != null)
            //    {
            //        if (conn.State == ConnectionState.Open)
            //        {
            //            conn.Close();
            //        }
            //    }
            //}

            #endregion
        }
        private void SaveManualPurchaseReturnToInventTransTable(string PurcReturnCode, SqlTransaction trans, SqlConnection conn, int Qty)
        {
            try
            {
                CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
                string TransLocation = "";

                if (Qty < 0)
                {
                    string    query1 = "select MainWarehouse from ax.inventsite where siteid='" + Session["SiteCode"].ToString() + "' ";
                    DataTable dt     = new DataTable();
                    dt = obj.GetData(query1);
                    if (dt.Rows.Count > 0)
                    {
                        TransLocation = dt.Rows[0]["MainWarehouse"].ToString();
                    }
                }
                else
                {
                    string    query1 = "Select INVENTLOCATIONID from Ax.inventlocation where InventSiteid = '" + Session["SiteCode"].ToString() + "'  and ACX_WAREHOUSETYPE = 1";
                    DataTable dt     = new DataTable();
                    dt = obj.GetData(query1);
                    if (dt.Rows.Count > 0)
                    {
                        TransLocation = dt.Rows[0]["INVENTLOCATIONID"].ToString();
                    }
                }


                string queryInsert = " Insert Into ax.acxinventTrans " +
                                     "([TransId],[SiteCode],[DATAAREAID],[RECID],[InventTransDate],[TransType],[DocumentType]," +
                                     "[DocumentNo],[DocumentDate],[ProductCode],[TransQty],[TransUOM],[TransLocation],[Referencedocumentno])" +
                                     " Values (@TransId,@SiteCode,@DATAAREAID,@RECID,@InventTransDate,@TransType,@DocumentType,@DocumentNo,@DocumentDate, " +
                                     " @ProductCode,@TransQty,@TransUOM,@TransLocation,@Referencedocumentno)";

                cmd                = new SqlCommand(queryInsert);
                cmd.Connection     = conn;
                cmd.Transaction    = trans;
                cmd.CommandTimeout = 0;
                cmd.CommandType    = CommandType.Text;

                string st = Session["SiteCode"].ToString();

                for (int i = 0; i < gvDetails.Rows.Count; i++)
                {
                    string   TransId             = st.Substring(st.Length - 6) + System.DateTime.Now.ToString("yymmddhhmmss");
                    string   Siteid              = Session["SiteCode"].ToString();
                    string   DATAAREAID          = Session["DATAAREAID"].ToString();
                    int      TransType           = 8;                           // Type 5 for Manual Purchase Return
                    int      DocumentType        = 8;
                    string   DocumentNo          = PurcReturnCode;
                    string   productNameCode     = gvDetails.Rows[i].Cells[2].Text;
                    string[] str                 = productNameCode.Split('-');
                    string   ProductCode         = str[0].ToString();
                    TextBox  txtBoxQty           = (TextBox)gvDetails.Rows[i].Cells[4].FindControl("txtQty");
                    string   strqty              = txtBoxQty.Text;
                    decimal  TransQty            = Convert.ToDecimal(strqty) * Qty;
                    string   UOM                 = gvDetails.Rows[i].Cells[7].Text;
                    string   Referencedocumentno = ddlInvoceNo.Text;// PurcReturnCode;
                    int      REcid               = i + 1;

                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@TransId", TransId);
                    cmd.Parameters.AddWithValue("@SiteCode", Siteid);
                    cmd.Parameters.AddWithValue("@DATAAREAID", DATAAREAID);
                    cmd.Parameters.AddWithValue("@RECID", i + 1);
                    cmd.Parameters.AddWithValue("@InventTransDate", DateTime.Now);
                    cmd.Parameters.AddWithValue("@TransType", TransType);
                    cmd.Parameters.AddWithValue("@DocumentType", DocumentType);
                    cmd.Parameters.AddWithValue("@DocumentNo", DocumentNo);
                    cmd.Parameters.AddWithValue("@DocumentDate", DateTime.Now);
                    cmd.Parameters.AddWithValue("@ProductCode", ProductCode);
                    cmd.Parameters.AddWithValue("@TransQty", TransQty);
                    cmd.Parameters.AddWithValue("@TransUOM", UOM);
                    cmd.Parameters.AddWithValue("@TransLocation", TransLocation);
                    cmd.Parameters.AddWithValue("@Referencedocumentno", ddlInvoceNo.SelectedItem.Value);
                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
Example #17
0
        protected void chkStatus_OnCheckedChanged(object sender, EventArgs e)                           //sale Header Grid View for Filling the Sale Line
        {
            try
            {
                string    strSONO = string.Empty;
                DataTable dt      = new DataTable();
                foreach (GridViewRow row in gvDetails.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        CheckBox chkRow = (row.Cells[0].FindControl("chkStatus") as CheckBox);
                        if (chkRow.Checked)
                        {
                            //strSONO += "'" + chkRow.Text + "',";                 //getting all So_No those are checked by User
                            strSONO += "" + chkRow.Text + ",";
                        }
                    }
                }
                //==============For Warehouse Loacion 11-5-16===========
                CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
                string TransLocation = "";

                string query1 = "select MainWarehouse from ax.inventsite where siteid='" + Session["SiteCode"].ToString() + "'";
                dt = new DataTable();
                dt = obj.GetData(query1);
                if (dt.Rows.Count > 0)
                {
                    TransLocation = dt.Rows[0]["MainWarehouse"].ToString();
                }
                //====================================
                if (strSONO != string.Empty)
                {
                    strSONO = strSONO.Remove(strSONO.Length - 1);

                    //==============11-5-16========
                    //string strSaleLine = "Select AP.PRODUCT_GROUP,AL.PRODUCT_CODE,AP.PRODUCT_NAME,Sum(AL.CRATES) as CRATES,cast(Sum(AL.BOX) as integer) As BOX,cast(Sum(AL.BOX) as decimal(9,2)) As TotalQty,Sum(AL.LTR) AS LTR ,Cast(Round((cast(Sum(AL.BOX) as decimal(9,2))-cast(Sum(AL.BOX) as integer))*AP.Product_PackSize,2) as integer) as PCS,AP.Product_PackSize" +
                    //                      ",StockBox=(Select coalesce(cast(sum(F.TransQty) as decimal(10,2)),0) as TransQty from [ax].[ACXINVENTTRANS] F where F.[SiteCode]=AL.SITEID and F.[ProductCode]=AL.Product_COde and F.[TransLocation]='" + TransLocation + "')" +
                    //                      ",StockLtr =(Select coalesce(cast((sum(F.TransQty)*AP.Product_PackSize*AP.LTR)/1000 as decimal(10,2)),0) as TransQty from [ax].[ACXINVENTTRANS] F where F.[SiteCode]=AL.SITEID and F.[ProductCode]=AL.Product_COde and F.[TransLocation]='" + TransLocation + "')" +
                    //                      " from [ax].[ACXSALESLINE] AL Inner Join [ax].[InventTable] AP on AL.PRODUCT_CODE = AP.ItemId " +
                    //                      " where SO_No In (" + strSONO + ") and  AL.SiteId='" + Session["SiteCode"].ToString() + "' group by AL.SITEID,AP.PRODUCT_GROUP,AL.PRODUCT_CODE,AP.PRODUCT_NAME,AP.Product_PackSize,AP.LTR";

                    string strSaleLine = "EXEC ACX_GETLOADSHEET '" + Session["SiteCode"].ToString() + "','" + TransLocation + "','" + strSONO + "'";

                    dt = baseObj.GetData(strSaleLine);
                    if (dt.Rows.Count > 0)
                    {
                        GridView2.Visible    = true;
                        GridView2.DataSource = dt;
                        GridView2.DataBind();

                        GridView2.FooterRow.Cells[2].Text            = "Total :";
                        GridView2.FooterRow.Cells[2].HorizontalAlign = HorizontalAlign.Right;
                        GridView2.FooterRow.Cells[2].ForeColor       = System.Drawing.Color.MidnightBlue;
                        GridView2.FooterRow.Cells[2].Font.Bold       = true;

                        decimal Crates = dt.AsEnumerable().Sum(row => row.Field <decimal>("CRATES"));
                        GridView2.FooterRow.Cells[3].Text            = Crates.ToString("N2");
                        GridView2.FooterRow.Cells[3].HorizontalAlign = HorizontalAlign.Right;
                        GridView2.FooterRow.Cells[3].ForeColor       = System.Drawing.Color.MidnightBlue;
                        GridView2.FooterRow.Cells[3].Font.Bold       = true;

                        int BoxQty = dt.AsEnumerable().Sum(row => row.Field <int>("BOX"));
                        GridView2.FooterRow.Cells[4].Text            = BoxQty.ToString();
                        GridView2.FooterRow.Cells[4].HorizontalAlign = HorizontalAlign.Right;
                        GridView2.FooterRow.Cells[4].ForeColor       = System.Drawing.Color.MidnightBlue;
                        GridView2.FooterRow.Cells[4].Font.Bold       = true;

                        int PCS = dt.AsEnumerable().Sum(row => row.Field <int>("PCS"));
                        GridView2.FooterRow.Cells[5].Text            = PCS.ToString();
                        GridView2.FooterRow.Cells[5].HorizontalAlign = HorizontalAlign.Right;
                        GridView2.FooterRow.Cells[5].ForeColor       = System.Drawing.Color.MidnightBlue;
                        GridView2.FooterRow.Cells[5].Font.Bold       = true;


                        decimal TotalQtyConv = dt.AsEnumerable().Sum(row => row.Field <decimal>("TotalQty"));
                        GridView2.FooterRow.Cells[6].Text            = TotalQtyConv.ToString("N2");
                        GridView2.FooterRow.Cells[6].HorizontalAlign = HorizontalAlign.Right;
                        GridView2.FooterRow.Cells[6].ForeColor       = System.Drawing.Color.MidnightBlue;
                        GridView2.FooterRow.Cells[6].Font.Bold       = true;


                        decimal ltr = dt.AsEnumerable().Sum(row => row.Field <decimal>("LTR"));
                        GridView2.FooterRow.Cells[8].Text            = ltr.ToString("N2");
                        GridView2.FooterRow.Cells[8].HorizontalAlign = HorizontalAlign.Right;
                        GridView2.FooterRow.Cells[8].ForeColor       = System.Drawing.Color.MidnightBlue;
                        GridView2.FooterRow.Cells[8].Font.Bold       = true;
                    }
                    else
                    {
                        dt = null;
                        GridView2.DataSource = dt;
                        GridView2.DataBind();
                    }
                }
                else
                {
                    dt = null;
                    GridView2.DataSource = dt;
                    GridView2.DataBind();
                }
                //UppnalegridDetails.Update();
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
Example #18
0
        private void ShowData(string CustID)
        {
            try
            {
                CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();

                string query = " Select *, B.CUSTGROUP_NAME, C.PSR_Name,D.BeatName,CG.Description As ChannelGroupName,CT.SubSegmentDescription As ChannelTypeName " +
                               " FROM  [ax].[ACXCUSTMASTER] A " +
                               " LEFT OUTER JOIN [AX].[ACXSMMBUSRELSEGMENTGROUP] CG ON CG.SegmentID= A.CHANNELGROUP " +
                               " LEFT OUTER JOIN [AX].[ACXSMMBUSRELSUBSEGMENTGROUP] CT ON CT.SubSegmentID= A.CHANNELTYPE " +
                               " LEFT OUTER JOIN ax.ACXCUSTGROUPMASTER B ON A.CUST_GROUP=B.CUSTGROUP_CODE " +
                               " LEFT OUTER JOIN [ax].[ACXPSRMaster] C ON A.PSR_CODE=C.PSR_Code LEFT OUTER JOIN " +
                               " [ax].[ACXPSRBeatMaster] D ON A.PSR_BEAT = D.BeatCode and A.SITE_CODE=D.Site_code where Customer_Code ='" + CustID + "' and A.BLOCKED=0";

                System.Data.DataTable dt = obj.GetData(query);
                if (dt.Rows.Count > 0)
                {
                    LiteralCustID.Text        = "[" + Request.QueryString["CustID"].ToString() + "] ";
                    txtCustomerName.Text      = dt.Rows[0]["Customer_Name"].ToString();
                    txtCustomerName.Font.Bold = true;
                    txtContactPerson.Text     = dt.Rows[0]["Contact_Name"].ToString();
                    txtAddress1.Text          = dt.Rows[0]["Address1"].ToString();
                    txtAddress2.Text          = dt.Rows[0]["Address2"].ToString();
                    txtCity.Text             = dt.Rows[0]["City"].ToString();
                    txtZipCode.Text          = dt.Rows[0]["ZipCode"].ToString();
                    txtArea.Text             = dt.Rows[0]["Area"].ToString();
                    txtDistrict.Text         = dt.Rows[0]["District"].ToString();
                    txtState.Text            = dt.Rows[0]["State"].ToString();
                    txtMobileNo.Text         = dt.Rows[0]["Mobile_No"].ToString();
                    txtMobileNo.Font.Bold    = true;
                    txtPhoneNo.Text          = dt.Rows[0]["Phone_No"].ToString();
                    txtEmailID.Text          = dt.Rows[0]["EmailId"].ToString();
                    txtPaymentTerm.Text      = dt.Rows[0]["Payment_Term"].ToString();
                    txtPaymentMode.Text      = dt.Rows[0]["Payment_Mode"].ToString();
                    txtPAN.Text              = dt.Rows[0]["Pan"].ToString();
                    txtTINVAT.Text           = dt.Rows[0]["VAT"].ToString();
                    txtCST.Text              = dt.Rows[0]["CST"].ToString();
                    txtTAN.Text              = dt.Rows[0]["TAN"].ToString();
                    txtRegDate.Text          = dt.Rows[0]["Register_Date"].ToString();
                    txtClosingDate.Text      = dt.Rows[0]["Closing_Date"].ToString();
                    txtCustGroup.Text        = "[" + dt.Rows[0]["CUST_GROUP"].ToString() + "]" + " " + dt.Rows[0]["CUSTGROUP_NAME"].ToString();
                    txtCustGroup.Font.Bold   = true;
                    txtDistance.Text         = string.Empty;
                    txtPSRName.Text          = "[" + dt.Rows[0]["PSR_Code"].ToString() + "]" + " " + dt.Rows[0]["PSR_Name"].ToString();
                    txtPSRName.Font.Bold     = true;
                    txtPSRBeatName.Text      = "[" + dt.Rows[0]["PSR_Beat"].ToString() + "]" + " " + dt.Rows[0]["BeatName"].ToString(); //+"/" + dt.Rows[0]["PSR_Day"].ToString();
                    txtPSRBeatName.Font.Bold = true;
                    txtDeepFreeer.Text       = dt.Rows[0]["Deep_Frizer"].ToString();
                    txtDeepFreeer.Font.Bold  = true;
                    txtDeepFreeer.ForeColor  = System.Drawing.Color.DarkGreen;
                    //txtChannelType.Text = dt.Rows[0]["Channel_Type"].ToString();
                    txtChannelGroup.Text   = dt.Rows[0]["ChannelGroupName"].ToString();
                    txtChannelType.Text    = dt.Rows[0]["ChannelTypeName"].ToString();
                    txtMonday.Text         = dt.Rows[0]["Monday"].ToString();
                    txtTuesday.Text        = dt.Rows[0]["Tuesday"].ToString();
                    txtWednesday.Text      = dt.Rows[0]["Wednesday"].ToString();
                    txtThursday.Text       = dt.Rows[0]["Thursday"].ToString();
                    txtFriday.Text         = dt.Rows[0]["Friday"].ToString();
                    txtSaturday.Text       = dt.Rows[0]["Saturday"].ToString();
                    txtSunday.Text         = dt.Rows[0]["Sunday"].ToString();
                    txtVisitFrequency.Text = dt.Rows[0]["VISITFREQUENCY"].ToString();
                    txtRepeatWeek.Text     = dt.Rows[0]["REPEATWEEK"].ToString();
                    txtSequenceno.Text     = dt.Rows[0]["SEQUENCENO"].ToString();
                    if (Convert.ToInt32(dt.Rows[0]["Key_Customer"].ToString()) == 0)
                    {
                        txtKeyCustomer.Text      = "No";
                        txtKeyCustomer.Font.Bold = true;
                        txtKeyCustomer.ForeColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        txtKeyCustomer.Text      = "Yes";
                        txtKeyCustomer.Font.Bold = true;
                        txtKeyCustomer.ForeColor = System.Drawing.Color.Green;
                    }
                    //txtKeyCustomer.Text = dt.Rows[0]["Key_Customer"].ToString();
                    if (Convert.ToInt32(dt.Rows[0]["Blocked"].ToString()) == 0)
                    {
                        txtActiveInactive.Text      = "Yes";
                        txtActiveInactive.Font.Bold = true;
                        txtActiveInactive.ForeColor = System.Drawing.Color.DarkGreen;
                    }
                    else
                    {
                        txtActiveInactive.Text      = "No";
                        txtActiveInactive.ForeColor = System.Drawing.Color.Red;
                    }
                    string APPLICABLESCHEMEDISCOUNT;
                    if (dt.Rows[0]["APPLICABLESCHEMEDISCOUNT"].ToString() == "0")
                    {
                        APPLICABLESCHEMEDISCOUNT = "None";
                    }
                    else if (dt.Rows[0]["APPLICABLESCHEMEDISCOUNT"].ToString() == "1")
                    {
                        APPLICABLESCHEMEDISCOUNT = "Scheme";
                    }
                    else if (dt.Rows[0]["APPLICABLESCHEMEDISCOUNT"].ToString() == "2")
                    {
                        APPLICABLESCHEMEDISCOUNT = "Discount";
                    }
                    else
                    {
                        APPLICABLESCHEMEDISCOUNT = "Both";
                    }
                    txtOutletType.Text = dt.Rows[0]["Outlet_Type"].ToString();
                    txtSchemeDisc.Text = APPLICABLESCHEMEDISCOUNT; //dt.Rows[0]["Scheme_Discount"].ToString();
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(GetType(), "Alert", " alert('No Data Exists !');", true);
                }
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtSearch.Text != "" || ddlSerch.SelectedItem.Text != "")
            {
                gvHeader.DataSource = null;
                gvHeader.DataBind();
                gvLineDetails.DataSource = null;
                gvLineDetails.DataBind();

                if (ddlSerch.SelectedItem.Text == "All")
                {
                    BindGridview();
                }
                else
                {
                    string search = "";
                    search = "%" + txtSearch.Text + "%";

                    if (Session["SaleOrderSearch"] == null)
                    {
                        string query = "EXEC [dbo].[ACX_GETPENDINGSO] '" + Session["SiteCode"].ToString() + "'";
                        CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
                        DataTable dt = new DataTable();
                        dt = obj.GetData(query);
                        Session["SaleOrderSearch"] = dt;
                        dt = null;
                    }
                    DataTable dtSearch = (DataTable)Session["SaleOrderSearch"];
                    DataRow[] drSearch;
                    if (ddlSerch.Text == "Customer Name")
                    {
                        drSearch = dtSearch.Select("Customer_Name like '" + search + "'");
                    }
                    else if (ddlSerch.SelectedItem.Text == "Date")
                    {
                        drSearch = dtSearch.Select("SO_Date='" + Convert.ToDateTime(txtSearch.Text).ToString("dd MMM yyyy") + "'");
                    }
                    else if (ddlSerch.SelectedItem.Text == "Load Sheet No")
                    {
                        drSearch = dtSearch.Select("LoadSheet_No like '" + search + "'");
                    }
                    else if (ddlSerch.SelectedItem.Text == "Customer Group")
                    {
                        drSearch = dtSearch.Select("Customer_Group like '" + search + "'");
                    }
                    else
                    {
                        drSearch = dtSearch.Select(ddlSerch.SelectedItem.Value + " like '" + search + "'");
                    }

                    if (drSearch.Count() > 0)
                    {
                        DataTable dt = drSearch.CopyToDataTable();
                        dt = SortDataView(dt);
                        gvHeader.DataSource = dt;
                        gvHeader.DataBind();
                        CheckBox chkbox = (CheckBox)gvHeader.HeaderRow.Cells[0].FindControl("CheckAll");
                        chkbox.Checked = true;
                        chkbox.Visible = true;
                        foreach (GridViewRow grv in gvHeader.Rows)
                        {
                            CheckBox chkAll = (CheckBox)grv.Cells[0].FindControl("chkSONO");
                            chkAll.Checked = true;
                        }
                        return;
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alerts", "javascript:alert('Record Not Found..')", true);
                        return;
                    }
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alerts", "javascript:alert('Enter the text in serchbox..')", true);
            }
        }