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);
            }
        }
Exemplo n.º 2
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); }
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        private void ShowDetails()
        {
            CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
            string        query = "ACX_USP_OpenSaleOrder";
            List <string> ilist = new List <string>();
            List <string> item  = new List <string>();
            DataTable     dt    = new DataTable();

            ilist.Add("@Site_Code"); item.Add(Session["SiteCode"].ToString());
            ilist.Add("@DATAAREAID"); item.Add(Session["DATAAREAID"].ToString());
            ilist.Add("@StartDate"); item.Add(txtFromDate.Text);
            ilist.Add("@EndDate"); item.Add(txtToDate.Text);

            dt = obj.GetData_New(query, CommandType.StoredProcedure, ilist, item);

            if (dt.Rows.Count > 0)
            {
                gvDetails.DataSource = dt;
                gvDetails.DataBind();
                LblMessage.Text   = "Total Records : " + dt.Rows.Count.ToString();
                Session["OpenSO"] = dt;
            }
            else
            {
                gvDetails.DataSource = dt;
                gvDetails.DataBind();
                LblMessage.Text = string.Empty;
            }
        }
 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);
     }
 }
Exemplo n.º 6
0
        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();

            SqlConnection conn           = null;
            SqlCommand    cmd            = null;
            DataTable     dtDataByfilter = null;
            string        query          = string.Empty;

            conn = new SqlConnection(obj.GetConnectionString());
            conn.Open();
            cmd                = new SqlCommand();
            cmd.Connection     = conn;
            cmd.CommandTimeout = 3600;
            cmd.CommandType    = CommandType.StoredProcedure;

            query = "[dbo].[ACX_GETUSERDETAILS]";

            cmd.CommandText = query;
            cmd.Parameters.AddWithValue("@State", ddlState.SelectedItem.Value);
            if (ddlSiteId.SelectedItem.Value == "All")
            {
                cmd.Parameters.AddWithValue("@SITECODE", "");
            }
            else
            {
                cmd.Parameters.AddWithValue("@SITECODE", ddlSiteId.SelectedItem.Value);
            }
            if (rdoDistributor.Checked == true)
            {
                cmd.Parameters.AddWithValue("@USERTYPE", "DISTRIBUTOR");
            }
            else
            {
                cmd.Parameters.AddWithValue("@USERTYPE", "PSRVRS");
            }

            dtDataByfilter = new DataTable();
            dtDataByfilter.Load(cmd.ExecuteReader());
            DataTable dt = new DataTable();

            dt = dtDataByfilter;

            if (dt.Rows.Count > 0)
            {
                gridLoginDetails.DataSource = dt;
                gridLoginDetails.DataBind();
                LblMessage.Text = "Total Records : " + dt.Rows.Count.ToString();
            }
            else
            {
                gridLoginDetails.DataSource = dt;
                gridLoginDetails.DataBind();

                LblMessage.Text = string.Empty;
            }
        }
Exemplo n.º 7
0
        private void LoadWarehouse()
        {
            CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
            string query1 = "SELECT INVENTLOCATIONID,NAME FROM AX.inventlocation WHERE INVENTSITEID='" + Session["SiteCode"].ToString() + "'";

            DDLWarehouseFrom.Items.Clear();
            DDLWarehouseFrom.Items.Add("-Select-");
            obj.BindToDropDown(DDLWarehouseFrom, query1, "NAME", "INVENTLOCATIONID");
            DDLWarehouseTo.Items.Clear();
            DDLWarehouseTo.Items.Add("-Select-");
            obj.BindToDropDown(DDLWarehouseTo, query1, "NAME", "INVENTLOCATIONID");
        }
Exemplo n.º 8
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();
            }
        }
Exemplo n.º 9
0
        protected void BindGridview()
        {
            try
            {
                CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
                DataTable     dt    = new DataTable();
                List <string> ilist = new List <string>();
                List <string> item  = new List <string>();
                ilist.Add("@ITEM_CATEGORY");
                item.Add(drpItemCategory.SelectedItem.Value);
                ilist.Add("@ITEM_CODE");
                item.Add(drpItemCode.SelectedItem.Value);
                ilist.Add("@ITEM_DESC");
                item.Add(DrpItemDescription.SelectedItem.Value);
                ilist.Add("@QTY_IN_PCS");
                item.Add(txtQTYPcs.Text.Trim());
                ilist.Add("@REMARK");
                item.Add(txtRemark.Text.Trim());


                if (dt.Rows.Count > 0)
                {
                    gvDetails.DataSource = dt;
                    gvDetails.DataBind();
                }
                else
                {
                    DataRow dr = null;
                    dr                  = dt.NewRow();
                    dr["Line_No"]       = 1;
                    dr["ITEM_CATEGORY"] = string.Empty;
                    dr["ITEM_CODE"]     = string.Empty;
                    dr["ITEM_NAME"]     = string.Empty;
                    dr["ITEM_DESC"]     = string.Empty;
                    dr["QTY_IN_PCS"]    = string.Empty;
                    dr["REMARK"]        = 0;
                    dt.Rows.Add(dr);
                    gvDetails.DataSource = dt;
                    gvDetails.DataBind();

                    int count = gvDetails.Rows.Count;
                    for (int i = count; i > 0; i--)
                    {
                        gvDetails.Rows[i - 1].Cells.Clear();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
        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);
            }
        }
Exemplo n.º 14
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);
            }
        }
Exemplo n.º 16
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);
            }
        }
Exemplo n.º 17
0
        private void ShowCurrentStock()
        {
            if (lstState.SelectedValue == string.Empty)
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "Validation", "alert('Please select atleast one state before show!');", true);
                return;
            }
            else if (lstSiteId.SelectedValue == string.Empty)
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "Validation", "alert('Please select atleast one distributor before show!');", true);
                return;
            }
            else if (ddlWarehouse.SelectedValue == string.Empty)
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "Validation", "alert('Please select atleast one Warehouse before show!');", true);
                return;
            }

            CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
            DataTable     dt    = new DataTable();
            List <string> ilist = new List <string>();
            List <string> item  = new List <string>();
            string        WareHouse;

            WareHouse = "";
            string siteid = "";

            foreach (System.Web.UI.WebControls.ListItem litem in ddlWarehouse.Items)
            {
                if (litem.Selected)
                {
                    if (WareHouse.Length == 0)
                    {
                        WareHouse = litem.Value.ToString();
                    }
                    else
                    {
                        WareHouse += "," + litem.Value.ToString();
                    }
                }
            }

            foreach (System.Web.UI.WebControls.ListItem litem in lstSiteId.Items)
            {
                if (litem.Selected)
                {
                    if (siteid.Length == 0)
                    {
                        siteid = litem.Value.ToString();
                    }
                    else
                    {
                        siteid += "," + litem.Value.ToString();
                    }
                }
            }

            string query = "ACX_CurrentStock";

            ilist.Add("@Site_Code"); item.Add(siteid.ToString());
            ilist.Add("@TransLocation"); item.Add(WareHouse);//item.Add("59144MW");//
            ilist.Add("@Dataareaid"); item.Add(Session["DATAAREAID"].ToString());
            if (ddlBuunit.SelectedIndex >= 1)
            {
                ilist.Add("@BUCODE"); item.Add(ddlBuunit.SelectedValue.ToString());
            }
            else
            {
                ilist.Add("@BUCODE"); item.Add("");
            }

            dt = obj.GetData_New(query, CommandType.StoredProcedure, ilist, item);

            if (dt.Rows.Count > 0)
            {
                //object sumLtr,SumQty,SumQtyLtr;
                //sumLtr = dt.Compute("Sum(LTR)", "");
                //SumQty = dt.Compute("Sum(Qty)", "");
                //SumQtyLtr = dt.Compute("Sum(QTYLtr)", "");
                //dt.Rows.Add("TOTAL", "", "", "0", sumLtr, "0", SumQty, SumQtyLtr, "0", "", "", "");
                gridCurrentStcok.DataSource = dt;
                gridCurrentStcok.DataBind();
                LblMessage.Text         = "Total Records : " + dt.Rows.Count.ToString();
                Session["CurrentStock"] = dt;
            }
            else
            {
                gridCurrentStcok.DataSource = dt;
                gridCurrentStcok.DataBind();

                LblMessage.Text = string.Empty;
            }
        }
        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
        }
Exemplo n.º 19
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                {
                    if (Session["LineItem"] != null)
                    {
                        CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
                        conn = obj.GetConnection();

                        DataTable dtNumSeq = obj.GetNumSequenceNew(12, Session["SiteCode"].ToString(), Session["DATAAREAID"].ToString());

                        string NUMSEQ = string.Empty;

                        string Code = string.Empty;
                        if (dtNumSeq != null)
                        {
                            Code   = dtNumSeq.Rows[0][0].ToString();
                            NUMSEQ = dtNumSeq.Rows[0][1].ToString();
                        }
                        else
                        {
                            return;
                        }

                        cmd1                = new SqlCommand("[dbo].[ACX_InventoryReceipt_POPLine]");
                        transaction         = conn.BeginTransaction();
                        cmd1.Connection     = conn;
                        cmd1.Transaction    = transaction;
                        cmd1.CommandTimeout = 3600;
                        cmd1.CommandType    = CommandType.StoredProcedure;

                        //=============Save Line=============
                        int i = 0;
                        foreach (GridViewRow grv in gvDetails.Rows)
                        {
                            HiddenField lblProduct = (HiddenField)grv.FindControl("HiddenValueItemCode");
                            Label       QTY        = (Label)grv.Cells[5].FindControl("QTY");
                            Label       Remark     = (Label)grv.Cells[5].FindControl("Remark");

                            i = i + 1;

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

                            cmd1.Parameters.Clear();
                            cmd1.Parameters.AddWithValue("@TransId", TransId);
                            cmd1.Parameters.AddWithValue("@Site_Code", lblsite.Text);
                            cmd1.Parameters.AddWithValue("@Line_No", i);
                            cmd1.Parameters.AddWithValue("@DOC_NO", Code);
                            cmd1.Parameters.AddWithValue("@ITEM_CODE", lblProduct.Value);
                            cmd1.Parameters.AddWithValue("@QTY_IN_PCS", QTY.Text);
                            cmd1.Parameters.AddWithValue("@REMARK", Remark.Text);
                            cmd1.Parameters.AddWithValue("@NumSeq", NUMSEQ);
                            cmd1.Parameters.AddWithValue("@DATAAREAID", Session["DATAAREAID"].ToString());
                            cmd1.ExecuteNonQuery();
                        }

                        // ==============Save Header=========
                        List <string> ilist = new List <string>();
                        List <string> litem = new List <string>();

                        cmd                = new SqlCommand("[dbo].[ACX_InventoryReceipt_POPHeader]");
                        cmd.Connection     = conn;
                        cmd.Transaction    = transaction;
                        cmd.CommandTimeout = 3600;
                        cmd.CommandType    = CommandType.StoredProcedure;

                        cmd.Parameters.AddWithValue("@Site_Code", Session["SiteCode"].ToString());
                        cmd.Parameters.AddWithValue("@SUPPLIER_NAME", txtSupplierName.Text);
                        cmd.Parameters.AddWithValue("@SUPPLIER_ADDRESS", txtSupplierAdd.Text);
                        cmd.Parameters.AddWithValue("@DOC_NO", Code);
                        cmd.Parameters.AddWithValue("@INVOICE_NO", txtDocumentNo.Text);
                        cmd.Parameters.AddWithValue("@INVOICE_DATE", txtDocumentDate.Text);
                        cmd.Parameters.AddWithValue("@NumSeq", NUMSEQ);
                        cmd.Parameters.AddWithValue("@DATAAREAID", Session["DATAAREAID"].ToString());

                        cmd.ExecuteNonQuery();
                        transaction.Commit();
                        lblMessage.Text = "Data Saved Successfully. POP Inventory Reciept No is:" + Code + "";
                        clear();
                    }
                    else
                    {
                        string message = "alert('Please Add Line Items First !');";
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", message, true);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                string message = "alert('Error:" + ex.Message + " !');";
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", message, true);
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
            finally
            {
                Session["LineItem"] = null;
                if (conn.State.ToString() == "Open")
                {
                    conn.Close();
                }
            }
        }
Exemplo n.º 20
0
        private void StockTransferTOWareHouse(string StockTransferCode, SqlTransaction trans, SqlConnection conn)      // Save Same Stock to WAREHOUSE OTHER LOCATION B //
        {
            CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
            //conn = obj.GetConnection();

            #region Stock Transfer Save for Warehouse TO Location

            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)";


            string st      = Session["SiteCode"].ToString();
            string TransId = st.Substring(st.Length - 6) + System.DateTime.Now.AddSeconds(2).ToString("yymmddhhmmss");            //SiteCode[6 Character] plus yymmddhhss of current time//

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

            #region Grid Data Insert Section

            for (int i = 0; i < gridStockTransferItems.Rows.Count; i++)
            {
                string   Siteid          = Session["SiteCode"].ToString();
                string   DATAAREAID      = Session["DATAAREAID"].ToString();
                int      TransType       = 6;                            // For Stock Transfer TransType //
                int      DocumentType    = 6;                            // For Stock Transfer TransType //
                string   DocumentNo      = StockTransferCode;            // Stock Transfer Number as generated by Code---//
                string   productNameCode = gridStockTransferItems.Rows[i].Cells[3].Text;
                string[] str             = productNameCode.Split('-');
                string   ProductCode     = str[0].ToString();
                decimal  TransQty        = Convert.ToDecimal(gridStockTransferItems.Rows[i].Cells[6].Text);
                string   UOM             = gridStockTransferItems.Rows[i].Cells[4].Text;

                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", RecID);
                cmd.Parameters.AddWithValue("@InventTransDate", DateTime.Now);
                cmd.Parameters.AddWithValue("@TransType", TransType);
                cmd.Parameters.AddWithValue("@DocumentType", DocumentType);
                cmd.Parameters.AddWithValue("@DocumentNo", DocumentNo);
                cmd.Parameters.AddWithValue("@Referencedocumentno", "");
                cmd.Parameters.AddWithValue("@DocumentDate", Convert.ToDateTime(txtDate.Text));
                cmd.Parameters.AddWithValue("@ProductCode", ProductCode);
                cmd.Parameters.AddWithValue("@TransQty", TransQty);                // for Stock add from WareHouse TO Location//
                cmd.Parameters.AddWithValue("@TransUOM", UOM);
                cmd.Parameters.AddWithValue("@TransLocation", DDLWarehouseTo.SelectedValue.ToString());

                cmd.ExecuteNonQuery();
            }

            #endregion

            #endregion

            //}
            //catch (Exception ex)
            //{
            //    transaction.Rollback();
            //}
        }
        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);
            }
        }
Exemplo n.º 22
0
        private void SaveDetails()
        {
            try
            {
                App_Code.Global obj = new App_Code.Global();
                //string Number="DT16000001";
                #region  getnTUMBER
                string Number = string.Empty;
                string query  = "SELECT ISNULL(MAX(CAST(RIGHT(DISTRUCTION_NO,6) AS INT)),0)+1 FROM [ax].[ACXDISTRUCTIONNOTE] where SITEID='" + Session["SiteCode"].ToString() + "'";
                conn = obj.GetConnection();
                cmd1 = new SqlCommand(query);

                transaction         = conn.BeginTransaction();
                cmd1.Connection     = conn;
                cmd1.Transaction    = transaction;
                cmd1.CommandTimeout = 3600;
                cmd1.CommandType    = CommandType.Text;
                object vc = cmd1.ExecuteScalar();


                Number = "DT" + System.DateTime.Today.ToString("yy") + ((int)vc).ToString("000000");
                #endregion

                #region insert into distruction table
                if (Session["ProductDetails"] != null)
                {
                    //conn = obj.GetConnection();
                    cmd = new SqlCommand("ACX_INSERTDISTRUCTIONNOTE");
                    // transaction = conn.BeginTransaction();
                    cmd.Connection     = conn;
                    cmd.Transaction    = transaction;
                    cmd.CommandTimeout = 3600;
                    cmd.CommandType    = CommandType.StoredProcedure;

                    int i = 0;
                    foreach (GridViewRow grv in gvDetails.Rows)
                    {
                        i = i + 1;
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@SITEID", Session["SITECODE"].ToString());
                        cmd.Parameters.AddWithValue("@DISTRUCTION_NO", Number);
                        cmd.Parameters.AddWithValue("@DATAAREAID", Session["DATAAREAID"].ToString());
                        cmd.Parameters.AddWithValue("@RECEIPT_NO", drpRecieptNo.SelectedItem.Text);
                        cmd.Parameters.AddWithValue("@RECEIPTDATE", txtReceiptDate.Text);
                        cmd.Parameters.AddWithValue("@INVOICE_NO", drpInvoceNo.SelectedItem.Text);
                        cmd.Parameters.AddWithValue("@INVOICEDATE", txtInvoiceDate.Text);
                        cmd.Parameters.AddWithValue("@LINENO", i);
                        cmd.Parameters.AddWithValue("@PRODUCTCODE", grv.Cells[1].Text);
                        cmd.Parameters.AddWithValue("@BOX", grv.Cells[3].Text);
                        cmd.Parameters.AddWithValue("@BATCHNO", grv.Cells[5].Text.Replace("&nbsp;", ""));
                        cmd.Parameters.AddWithValue("@MFD", grv.Cells[6].Text);
                        cmd.Parameters.AddWithValue("@REMARK", grv.Cells[7].Text.Replace("&nbsp;", ""));
                        cmd.Parameters.AddWithValue("@PRICE", grv.Cells[8].Text);
                        cmd.Parameters.AddWithValue("@VALUE", Convert.ToDecimal(grv.Cells[9].Text));
                        cmd.Parameters.AddWithValue("@DISTRUCTIONTYPE", 0);
                        cmd.ExecuteNonQuery();
                    }
                    #endregion

                    #region  insert into transaction table and claim table

                    cmd2                = new SqlCommand("ACX_DISTRUCTION_STOCK_MOVEMENT");
                    cmd2.Connection     = conn;
                    cmd2.Transaction    = transaction;
                    cmd2.CommandTimeout = 3600;
                    cmd2.CommandType    = CommandType.StoredProcedure;

                    cmd2.Parameters.Clear();
                    cmd2.Parameters.AddWithValue("@Siteid", Session["SITECODE"].ToString());
                    cmd2.Parameters.AddWithValue("@DISTRUCTIONTYPE", 0);
                    cmd2.Parameters.AddWithValue("@DISTRUCTION_NO", Number);

                    cmd2.ExecuteNonQuery();

                    #endregion

                    transaction.Commit();
                    ClearAll();
                    string message = "alert('Distruction No : " + Number + " Generated Successfully.!');";
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", message, true);
                }
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                string message = "alert('Error:" + ex.Message + " !');";
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", message, true);
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
            finally
            {
                if (conn != null)
                {
                    if (conn.State.ToString() == "Open")
                    {
                        conn.Close();
                        conn.Dispose();
                    }
                }
            }
        }
Exemplo n.º 23
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);
            }
        }
Exemplo n.º 24
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);
            }
        }
        protected void btnBulkInv_Click(object sender, EventArgs e)
        {
            CreamBell_DMS_WebApps.App_Code.Global obj = new App_Code.Global();
            SqlConnection con = obj.GetConnection();
            SqlCommand    cmd = new SqlCommand();

            cmd.CommandType    = CommandType.Text;
            cmd.CommandTimeout = 3600;
            try
            {
                int    count    = 0;
                string SO_NO    = string.Empty;
                string custname = string.Empty;
                foreach (GridViewRow rw in gvHeader.Rows)
                {
                    CheckBox chkBx       = (CheckBox)rw.FindControl("chkSONO");
                    Label    lblCustName = (Label)rw.FindControl("Customer_Name");


                    if (chkBx != null && chkBx.Checked)
                    {
                        count += 1;
                        int row = rw.RowIndex;

                        custname = lblCustName.Text;
                        LinkButton lblSOno = (LinkButton)gvHeader.Rows[row].FindControl("lnkbtn");
                        Label      lblinv  = (Label)gvHeader.Rows[row].FindControl("Invoice_No");
                        if (lblSOno.Text != "")
                        {
                            if (lblinv.Text == "")
                            {
                                SO_NO += "" + lblSOno.Text + ",";
                            }
                        }
                    }

                    lblMessge.Text = "";
                }
                if (count > 8)
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alerts", "alert('Maximum 8 sale order selected in single bulk invoice generation');", true);
                    return;
                }
                SO_NO           = SO_NO.Remove(SO_NO.Length - 1);
                cmd.Connection  = con;
                cmd.CommandText = "EXEC AX.ACX_SOTOINVOICECREATION_BULK '" + Session["TransLocation"] + "','" + Session["SiteCode"] + "','" + SO_NO + "'";
                DataTable dt = new DataTable();
                dt.Load(cmd.ExecuteReader());
                gridviewRecords.DataSource = dt;
                gridviewRecords.Visible    = true;
                gridviewRecords.DataBind();
                ModalPopupExtender1.Show();
                ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", "javascript:MyMessage(" + dt.Rows.Count + "," + dt.Select("Remarks='Success'").Count() + ");", true);
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "javascript:MyMessage("+dt.Rows.Count+","+dt.Select("Remarks='Success'").Count() +");", true);
                //Response.Write("<script>alert('test');</script>");
                //ScriptManager.RegisterClientScriptBlock((sender as Control), this.GetType(), "alert", "alert('test');", true);
            }
            catch (Exception ex)
            {
                ErrorSignal.FromCurrentContext().Raise(ex);
            }
        }
Exemplo n.º 26
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();
        }
Exemplo n.º 27
0
        private void SaveStockTransferToDB()
        {
            try
            {
                //var watch = System.Diagnostics.Stopwatch.StartNew();
                // the code that you want to measure comes here

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

                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)";


                string st      = Session["SiteCode"].ToString();
                string TransId = st.Substring(st.Length - 6) + System.DateTime.Now.ToString("yymmddhhmmss");        //SiteCode[6 Character] plus yymmddhhss of current time//

                //string TransId = obj.GetNumSequence(10, Session["SiteCode"].ToString(), Session["DATAAREAID"].ToString());

                #region Generate New Code for Stock Transfer

                string _query = "SELECT ISNULL(MAX(CAST(RIGHT(DocumentNo,10) AS INT)),0)+1 FROM [ax].[ACXINVENTTRANS] " +
                                "where SITECODE='" + Session["SiteCode"].ToString() + "' and TransType=6";

                cmd                = new SqlCommand(_query);
                transaction        = conn.BeginTransaction();
                cmd.Connection     = conn;
                cmd.Transaction    = transaction;
                cmd.CommandTimeout = 3600;
                cmd.CommandType    = CommandType.Text;
                object vc = cmd.ExecuteScalar();

                string strCodeforStockTransfer = "ST-" + ((int)vc).ToString("0000000000");          //--Stock Transfer Number [ST-0000000001] ---//

                #endregion

                cmd.CommandText = string.Empty;
                cmd.CommandText = queryInsert;

                #region Grid Data Insert for Warehouse A

                for (int i = 0; i < gridStockTransferItems.Rows.Count; i++)
                {
                    string Siteid       = Session["SiteCode"].ToString();
                    string DATAAREAID   = Session["DATAAREAID"].ToString();
                    int    TransType    = 6;                                   // For Stock Transfer TransType //
                    int    DocumentType = 6;                                   // For Stock Transfer TransType //
                    string DocumentNo   = strCodeforStockTransfer;             // Stock Transfer Number as generated by Code---//

                    string   productNameCode = gridStockTransferItems.Rows[i].Cells[3].Text;
                    string[] str             = productNameCode.Split('-');
                    string   ProductCode     = str[0].ToString();
                    decimal  TransQty        = Convert.ToDecimal(gridStockTransferItems.Rows[i].Cells[6].Text);
                    string   UOM             = gridStockTransferItems.Rows[i].Cells[4].Text;

                    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", RecID);
                    cmd.Parameters.AddWithValue("@InventTransDate", DateTime.Now);
                    cmd.Parameters.AddWithValue("@TransType", TransType);
                    cmd.Parameters.AddWithValue("@DocumentType", DocumentType);
                    cmd.Parameters.AddWithValue("@DocumentNo", DocumentNo);
                    cmd.Parameters.AddWithValue("@Referencedocumentno", "");
                    cmd.Parameters.AddWithValue("@DocumentDate", Convert.ToDateTime(txtDate.Text));
                    cmd.Parameters.AddWithValue("@ProductCode", ProductCode);
                    cmd.Parameters.AddWithValue("@TransQty", TransQty * -1);            // for Stock less from WareHouse From Location//
                    cmd.Parameters.AddWithValue("@TransUOM", UOM);
                    cmd.Parameters.AddWithValue("@TransLocation", DDLWarehouseFrom.SelectedValue.ToString());

                    cmd.ExecuteNonQuery();
                    ViewState["AdjustmentNo"] = TransId;
                }

                #endregion



                StockTransferTOWareHouse(strCodeforStockTransfer, transaction, conn);

                //obj.UpdateLastNumSequence(10, Session["SiteCode"].ToString(), Session["DATAAREAID"].ToString(), conn, transaction);

                transaction.Commit();
                //watch.Stop();
                //var elapsedMs = watch.ElapsedMilliseconds;
                // this.Page.ClientScript.RegisterStartupScript(GetType(), "Alert", " alert('Transfer No: " + strCodeforStockTransfer +  " .Stock Transferred from "+DDLWarehouseTo.Text.ToString()+ " to "+DDLWarehouseTo.Text+ " Successfully !!. ');", true);

                string message = " alert('Transfer No: " + strCodeforStockTransfer + " .Stock Transferred from " + DDLWarehouseFrom.Text.ToString() + " to " + DDLWarehouseTo.Text + " Successfully !!. ');";
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", message, true);

                ResetAllControls();
                cmd.Dispose();
                conn.Close();
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                LblMessage.Text = "► Stock Not Transffered. " + " Error: " + ex.Message.ToString();
                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);
            }
        }