private void GetSalesManager()
    {
        DataTable ds = new DataTable();

        try
        {
            ds = ClsPurchaseInvoice.Get_PurchaseOrderForPurchaseInvoiceApproval(Convert.ToDateTime(Txt_FromDate.Text.Trim()), Convert.ToDateTime(Txt_ToDate.Text.Trim()));
            if (ds.Rows.Count > 0)
            {
                GvwSalesRegister.Visible    = true;
                GvwSalesRegister.DataSource = ds;
                GvwSalesRegister.DataBind();
                ViewState["Data"] = ds;
                ds.Dispose();
                if (ViewState["PageINdex"] != null)
                {
                    GvwSalesRegister.PageIndex = Convert.ToInt32(ViewState["PageINdex"].ToString());
                }
                lblmsg.Text = "";
            }
            else
            {
                GvwSalesRegister.Visible = false;
                lblmsg.Text = "NO Data Found...";
                // ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('NO Data Found...');</script>", false);
            }
        }
        catch (Exception ex)
        {
        }
    }
Esempio n. 2
0
    private void PoDetails(Int64 id)
    {
        DataTable ds = new DataTable();

        ds = ClsPurchaseInvoice.Get_PurchaseOrderForInvoice(id);
        GvwSaleseOrderDetails.DataSource = ds;
        GvwSaleseOrderDetails.DataBind();
    }
    private void PoDetails(Int64 id)
    {
        DataTable ds = new DataTable();

        ds = ClsPurchaseInvoice.Get_PurchaseOrderForInvoiceInInvoiceApproval(id);
        GvwPurchaseInvocie.DataSource = ds;
        GvwPurchaseInvocie.DataBind();
        if (ds.Rows.Count > 0)
        {
            Txt_InvoiceNo.Text = ds.Rows[0]["InvoiceNumber"].ToString();
            string Invoicedate = ds.Rows[0]["InvoiceDate"].ToString();
            Txt_InvoiceDate.Text = GetDefaultStartDate(Convert.ToDateTime(Invoicedate));
        }
    }
Esempio n. 4
0
    private void GetSalesManager()
    {
        DataTable ds = new DataTable();

        try
        {
            ds = ClsPurchaseInvoice.Get_PurchaseOrderForPurchaseInvoice(Convert.ToDateTime(Txt_FromDate.Text.Trim()), Convert.ToDateTime(Txt_ToDate.Text.Trim()));
            GvwSalesRegister.DataSource = ds;
            GvwSalesRegister.DataBind();
            ViewState["Data"] = ds;
            ds.Dispose();
            if (ViewState["PageINdex"] != null)
            {
                GvwSalesRegister.PageIndex = Convert.ToInt32(ViewState["PageINdex"].ToString());
            }
        }
        catch (Exception ex)
        {
        }
    }
    private void GetSalesManagerSupport()
    {
        DataTable ds = new DataTable();

        try
        {
            ds = ClsPurchaseInvoice.Get_PurchaseOrderForInvoice(value);
            GvwSaleseOrderDetailsSupport.DataSource = ds;
            GvwSaleseOrderDetailsSupport.DataBind();
            ViewState["Data"] = ds;
            ds.Dispose();
            if (ViewState["PageINdex"] != null)
            {
                GvwSaleseOrderDetailsSupport.PageIndex = Convert.ToInt32(ViewState["PageINdex"].ToString());
            }
        }
        catch (Exception ex)
        {
        }
    }
    private void GetSalesManager()
    {
        DataTable ds = new DataTable();

        try
        {
            ds = ClsPurchaseInvoice.Get_PurchaseOrderForPurchaseInvoice(Convert.ToDateTime(Txt_FromDate.Text.Trim()), Convert.ToDateTime(Txt_ToDate.Text.Trim()));
            if (ds.Rows.Count > 0)
            {
                lblMsg.Text = "";
                GvwSalesRegister.Visible    = true;
                GvwSalesRegister.DataSource = ds;
                GvwSalesRegister.DataBind();
                ViewState["Data"] = ds;
                ds.Dispose();
                if (ViewState["PageINdex"] != null)
                {
                    GvwSalesRegister.PageIndex = Convert.ToInt32(ViewState["PageINdex"].ToString());
                }

                for (int i = 0; i < ds.Rows.Count; i++)
                {
                    DataTable dtPartial = ClsPurchaseInvoice.GetPartialdataBasedOnPONum(ds.Rows[i]["GRN_Number"].ToString());
                    if (dtPartial.Rows.Count > 0)
                    {
                        GvwSalesRegister.Rows[i].Cells[1].BackColor = System.Drawing.Color.Yellow;
                    }
                }
            }
            else
            {
                GvwSalesRegister.Visible = false;
                lblMsg.Text = "No Records Found";
                // ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('NO Data Found...');</script>", false);
            }
        }
        catch (Exception ex)
        {
        }
    }
    private void GetSalesManagerAMC1()
    {
        DataTable ds = new DataTable();

        try
        {
            ds = ClsPurchaseInvoice.Get_PurchaseOrderForInvoicePDF(value);
            int    count = ds.Rows.Count;
            double total = Convert.ToDouble(ds.Rows[count - 1]["TT"].ToString());
            StrRupInWord         = "Word: " + AmountInWords(Convert.ToDecimal(total));
            GridView1.DataSource = ds;
            GridView1.DataBind();
            ViewState["Data"] = ds;
            ds.Dispose();
            if (ViewState["PageINdex"] != null)
            {
                GridView1.PageIndex = Convert.ToInt32(ViewState["PageINdex"].ToString());
            }
        }
        catch (Exception ex)
        {
        }
    }
    public void AddNewGridRow1()
    {
        BtnInvoiceSave0.Visible = true;
        double SubTotal = 0; double POSubTotal = 0;

        double Total = 0;

        foreach (GridViewRow row in GvwPurchaseInvocie.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                if (((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text == "")
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('please Enter Invoice Quantity.');</script>", false);
                    return;
                }
                string    HidCatagory0 = ((HiddenField)row.Cells[3].FindControl("HidCatagory0")).Value;
                string    HidProduct0  = ((HiddenField)row.Cells[3].FindControl("HidProduct0")).Value;
                DataTable DT           = ClsCheck.Get_PurchaseCheck(TxtPoNo.Text.Trim(), Convert.ToInt32(HidProduct0), Convert.ToInt32(HidCatagory0));
                int       POQUANTITY   = Convert.ToInt32(((Label)row.Cells[2].FindControl("LblPendingQuantity")).Text);
                double    POPrice      = Convert.ToDouble(((Label)row.Cells[2].FindControl("LblPrice")).Text);
                // int POQUANTITY = Convert.ToInt32(DT.Rows[0]["PO_QUANTITY"].ToString());
                // int PURCHASEIN = Convert.ToInt32(DT.Rows[0]["PURCHASE_INVOICE"].ToString());
                int TxtInQuantity1 = Convert.ToInt32(((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text);

                if (POQUANTITY < TxtInQuantity1)
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Invoice Quantity is greater than Purchase Quantity..');</script>", false);
                    return;
                }

                string PoNo       = TxtPoNo.Text;
                int    CategoryId = Convert.ToInt32(((HiddenField)row.FindControl("HidCatagory0")).Value);
                int    ProductId  = Convert.ToInt32(((HiddenField)row.FindControl("HidProduct0")).Value);
                Int32  Quantity   = Convert.ToInt32(((TextBox)row.Cells[2].FindControl("TxtInQuantity")).Text);
                double totalprice = Convert.ToDouble(((TextBox)row.Cells[2].FindControl("TxtInPrice")).Text);

                // int lblSubTot = Convert.ToInt32(((TextBox)GvwPurchaseInvocie.FooterRow.FindControl("TxtInQuantity")).Text) * Convert.ToInt32(((TextBox)GvwPurchaseInvocie.FooterRow.FindControl("TxtInPrice")).Text);
                int    TxtInQuantity = Convert.ToInt32(((TextBox)row.FindControl("TxtInQuantity")).Text);
                double TxtInPrice    = Convert.ToDouble(((TextBox)row.FindControl("TxtInPrice")).Text);

                double TotalPrice = POQUANTITY * Convert.ToDouble(POPrice);

                Label lblPototalPrice = (Label)row.FindControl("LblPOTotalPrice");
                lblPototalPrice.Text = Convert.ToString(TotalPrice.ToString("0.00"));

                double lblSubTot = TxtInQuantity * Convert.ToDouble(TxtInPrice);

                TextBox TxtInTotalPrice = (TextBox)row.FindControl("TxtInTotalPrice");
                TxtInTotalPrice.Text = Convert.ToString(lblSubTot.ToString("0.00"));

                // int lblSubTot = Convert.ToInt32(((TextBox)row.FindControl("TxtInQuantity")).Text) * Convert.ToInt32(((TextBox)row.FindControl("TxtInPrice")).Text);

                DataTable DTTaxRate = new DataTable();
                DTTaxRate = ClsPurchaseInvoice.GetInvoiceTaxRateBaseValue(PoNo, CategoryId, ProductId);
                // Label lblSubTot = (Label)GvwPurchaseOrder.FooterRow.FindControl("LblfttotalPrice");
                double TaxValue = 0; double POTaxValue = 0;
                if (DTTaxRate.Rows.Count > 0)
                {
                    for (int i = 0; i <= DTTaxRate.Rows.Count - 1; i++)
                    {
                        double POSubTotalbaseVal = Convert.ToDouble(TotalPrice) * Convert.ToDouble(DTTaxRate.Rows[i][2].ToString()) / 100;

                        double SubTotonBaseVal = Convert.ToDouble(lblSubTot) * Convert.ToDouble(DTTaxRate.Rows[i][2].ToString()) / 100;

                        POTaxValue = POTaxValue + (POSubTotalbaseVal * Convert.ToDouble(DTTaxRate.Rows[i][1].ToString()) / 100);

                        TaxValue = TaxValue + (SubTotonBaseVal * Convert.ToDouble(DTTaxRate.Rows[i][1].ToString()) / 100);
                    }
                }

                POTotalAmount = Convert.ToDouble(TotalPrice) + POTaxValue;
                TotalAmount   = Convert.ToDouble(lblSubTot) + TaxValue;

                // double tax = Convert.ToDouble(((TextBox)row.Cells[2].FindControl("txttaxid")).Text);
                // Total = (((Convert.ToDouble(totalprice * Quantity)) * tax) / 100) + (((Convert.ToDouble(totalprice * Quantity))));
                TextBox TxtInvTax = (TextBox)row.FindControl("txttaxid");
                TxtInvTax.Text = Convert.ToString(TaxValue.ToString("0.00"));

                Label Lbltaxid = (Label)row.FindControl("Lbltaxid");
                Lbltaxid.Text = Convert.ToString(POTaxValue.ToString("0.00"));

                Label LbltotalAmount = (Label)row.FindControl("LbltotalAmount");
                LbltotalAmount.Text = POTotalAmount.ToString("0.00");

                Label lbl = (Label)(row.Cells[2].FindControl("LblInvocietotalPrice"));
                lbl.Text   = TotalAmount.ToString("0.00");
                POSubTotal = POSubTotal + POTotalAmount;
                SubTotal   = SubTotal + TotalAmount;
            }
        }
        // TxtInTotalAmount.Text = Math.Floor(POSubTotal + .49).ToString("0.00");
        TxtInTotalAmount.Text = Convert.ToDouble(POSubTotal).ToString("0.00");
        // Txt_SubTotal.Text = Math.Floor(SubTotal + .49).ToString("0.00");
        Txt_SubTotal.Text = Convert.ToDouble(SubTotal).ToString("0.00");
    }
    protected void BtnInvoiceSave_Click(object sender, EventArgs e)
    {
        try
        {
            ClsPurchaseInvoice objclsinvc = new ClsPurchaseInvoice();
            if (Txt_InvoiceNo.Text != string.Empty && Txt_InvoiceDate.Text != string.Empty)
            {
                foreach (GridViewRow row in GvwPurchaseInvocie.Rows)
                {
                    if (((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text == "")
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('please Enter Invoice Quantity.');</script>", false);
                        return;
                    }
                    double TxtInPriceUpdate      = Convert.ToDouble(((TextBox)row.FindControl("TxtInPrice")).Text);
                    double TxtInTotalPriceUpdate = Convert.ToDouble(((TextBox)row.FindControl("TxtInTotalPrice")).Text);
                    Int32  TxtInQuantityUpdate   = Convert.ToInt32(((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text);
                    double Sum    = Convert.ToDouble((TxtInPriceUpdate * TxtInQuantityUpdate).ToString("0.00"));
                    double prvSum = Convert.ToDouble(TxtInTotalPriceUpdate.ToString("0.00"));
                    if (Sum != prvSum)
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "PopupScript", "<script type=text/javascript>alert('Please click on Update Button..')</script>");
                        Button BtnAdd = (Button)GvwPurchaseInvocie.FooterRow.FindControl("BtnAdd");
                        BtnAdd.Focus();
                        return;
                    }
                }
                //Check point
                //--t_purchase order detail and t_purchareinvoicedetail
                //string pono = TxtPoNo.Text;
                foreach (GridViewRow row in GvwPurchaseInvocie.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        string    HidCatagory0 = ((HiddenField)row.Cells[3].FindControl("HidCatagory0")).Value;
                        string    HidProduct0  = ((HiddenField)row.Cells[3].FindControl("HidProduct0")).Value;
                        DataTable DT           = ClsCheck.Get_PurchaseCheck(TxtGRNNum.Text.Trim(), Convert.ToInt32(HidProduct0), Convert.ToInt32(HidCatagory0));
                        int       POQUANTITY   = Convert.ToInt32(((Label)row.Cells[2].FindControl("LblQuantity")).Text);

                        //int POQUANTITY = Convert.ToInt32(DT.Rows[0]["PO_QUANTITY"].ToString());
                        //int PURCHASEIN = Convert.ToInt32(DT.Rows[0]["PURCHASE_INVOICE"].ToString());
                        int TxtInQuantity = Convert.ToInt32(((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text);

                        if (POQUANTITY < TxtInQuantity)
                        {
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Invoice Quantity is greater than Purchase Quantity..');</script>", false);
                            return;
                        }
                    }
                }

                string   asd       = hidDetails_ID.Value;
                DateTime PODATE    = Convert.ToDateTime(TxtPoDate.Text);
                string   GRNnumber = TxtGRNNum.Text;

                int      invoiceid;
                DateTime invoicedate = DateTime.Now;
                string   invoiceno = ""; string totalAmount = "";
                invoicedate = Convert.ToDateTime(Txt_InvoiceDate.Text.Trim());
                invoiceno   = Txt_InvoiceNo.Text.Trim();
                totalAmount = Txt_SubTotal.Text.Trim();


                //taxid = Convert.ToInt32(DrpTaxType.SelectedItem.Value);
                result2 = ClsPurchaseInvoice.InsertPurchaseGRNInvoice(out invoiceid, Convert.ToInt32(asd), GRNnumber, PODATE,
                                                                      invoiceno, invoicedate, Convert.ToDouble(totalAmount), Convert.ToInt32(Session["Id"]), "");
                if (result2)
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('invoice Saved Successfully...');</script>", false);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('invoice Insertion Failed...');</script>", false);
                }


                foreach (GridViewRow row in GvwPurchaseInvocie.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        string LblSlno       = ((Label)row.Cells[0].FindControl("LblSlno")).Text;
                        Int64  HidPODetId    = Convert.ToInt32(((HiddenField)row.Cells[2].FindControl("HdfPODETID")).Value);
                        string lblCatagory   = ((Label)row.Cells[1].FindControl("lblCatagory")).Text;
                        Int32  HidCatagory0  = Convert.ToInt32(((HiddenField)row.Cells[2].FindControl("HidCatagory0")).Value);
                        string LblProduct    = ((Label)row.Cells[3].FindControl("LblProduct")).Text;
                        Int32  HidProduct0   = Convert.ToInt32(((HiddenField)row.Cells[4].FindControl("HidProduct0")).Value);
                        Int32  LblQuantity   = Convert.ToInt32(((Label)row.Cells[3].FindControl("LblQuantity")).Text);
                        double LblPrice      = Convert.ToDouble(((Label)row.Cells[3].FindControl("LblPrice")).Text);
                        double POTaxPrice    = Convert.ToDouble(((Label)row.Cells[3].FindControl("Lbltaxid")).Text);
                        double pototalamount = Convert.ToDouble(((Label)row.Cells[3].FindControl("LbltotalAmount")).Text);

                        string TxtInQuantity      = ((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text;
                        string TxtInPrice         = ((TextBox)row.Cells[4].FindControl("TxtInPrice")).Text;
                        double invoicetotalamount = Convert.ToDouble(((Label)row.Cells[3].FindControl("LblInvocietotalPrice")).Text);
                        string InvoiceTaxPrice    = ((TextBox)row.Cells[3].FindControl("txttaxid")).Text;

                        string loaction     = Txt_shippingAdress.Text.Trim();
                        string MainLocation = TxtPoLocation.Text;

                        result1 = ClsPurchaseInvoice.InsertPurchaseGRNInvoicedetails(invoiceid, Convert.ToInt32(asd), HidCatagory0, HidProduct0,
                                                                                     LblQuantity, LblPrice, POTaxPrice, pototalamount,
                                                                                     Convert.ToInt32(TxtInQuantity), Convert.ToDouble(TxtInPrice), InvoiceTaxPrice, invoicetotalamount, Convert.ToInt32(Session["Id"].ToString()), loaction, LblProduct, invoicedate, MainLocation, Convert.ToInt32(Session["int_LocationId"]), HidPODetId);
                    }
                }

                Txt_InvoiceNo.Text   = "";
                Txt_InvoiceDate.Text = "";
                Txt_SubTotal.Text    = "0.00";

                TxtInTotalAmount.Text = "0.00";
                GetSalesManager();
                Panel1.Visible = false; Panel2.Visible = true; tbldate.Visible = true;
            }
            else
            {
                if (Txt_InvoiceNo.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Enter Invoice Number.');</script>", false);
                    Txt_InvoiceNo.Focus();
                    return;
                }
                if (Txt_InvoiceDate.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select Invoice Date.');</script>", false);
                    Txt_InvoiceDate.Focus();
                    return;
                }
                //if (Txt_InvoiceDate.Text != "")
                //{
                //    DateTime PODate = Convert.ToDateTime(TxtPoDate.Text);
                //    DateTime PO_date = Convert.ToDateTime(PODate.ToString("dd/MM/yyyy"));
                //    DateTime InvoiceDate = Convert.ToDateTime(Txt_InvoiceDate.Text);
                //    DateTime Invoice_Date = Convert.ToDateTime(InvoiceDate.ToString("dd/MM/yyyy"));
                //    if (PO_date > Invoice_Date)
                //    {
                //        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Invoice Date Should be Greater Than PO Date.');</script>", false);
                //        TxtPoDate.Focus();
                //        return;
                //    }
                //}
                //if (TxtLorryRcptNum.Text == "")
                //{
                //    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Enter Lorry receipt number.');</script>", false);
                //    TxtLorryRcptNum.Focus();
                //    return;

                //}
                // ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Fill Invoice Number and Invoice Date...');</script>", false);
            }
        }
        catch (Exception ex)
        {
        }
    }
    protected void BtnInvoiceSave_Click(object sender, EventArgs e)
    {
        try
        {
            ClsPurchaseInvoice objclsinvc = new ClsPurchaseInvoice();
            if (Txt_InvoiceNo.Text != string.Empty && Txt_InvoiceDate.Text != string.Empty)
            {
                if (ddlInvoiceApproval.SelectedValue == "1")
                {
                    string   asd      = hidDetails_ID.Value;
                    DateTime PODATE   = Convert.ToDateTime(TxtPoDate.Text);
                    string   ponumber = TxtPoNo.Text;

                    int      invoiceid;
                    DateTime invoicedate = DateTime.Now;
                    string   invoiceno = ""; string totalAmount = "";
                    invoicedate = Convert.ToDateTime(Txt_InvoiceDate.Text.Trim());
                    invoiceno   = Txt_InvoiceNo.Text.Trim();

                    totalAmount = Txt_SubTotal.Text.Trim();
                    //taxid = Convert.ToInt32(DrpTaxType.SelectedItem.Value);

                    result2 = ClsPurchaseInvoice.InsertPurchaseInvoiceFromInvoiceApproval(out invoiceid, Convert.ToInt32(asd), ponumber, PODATE,
                                                                                          invoiceno, invoicedate, Convert.ToDouble(totalAmount), Convert.ToInt32(Session["Id"]), Convert.ToInt32(ddlInvoiceApproval.SelectedValue));
                    if (result2)
                    {
                        //Panel1.Visible = false;
                        //Panel2.Visible = true;
                        //tbldate.Visible = true;
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('invoice Saved Successfully...');</script>", false);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('invoice Insertion Failed...');</script>", false);
                    }


                    foreach (GridViewRow row in GvwPurchaseInvocie.Rows)
                    {
                        if (row.RowType == DataControlRowType.DataRow)
                        {
                            string LblSlno       = ((Label)row.Cells[0].FindControl("LblSlno")).Text;
                            string lblCatagory   = ((Label)row.Cells[1].FindControl("lblCatagory")).Text;
                            Int32  HidCatagory0  = Convert.ToInt32(((HiddenField)row.Cells[2].FindControl("HidCatagory0")).Value);
                            string LblProduct    = ((Label)row.Cells[3].FindControl("LblProduct")).Text;
                            Int32  HidProduct0   = Convert.ToInt32(((HiddenField)row.Cells[4].FindControl("HidProduct0")).Value);
                            Int32  LblQuantity   = Convert.ToInt32(((Label)row.Cells[3].FindControl("LblQuantity")).Text);
                            double LblPrice      = Convert.ToDouble(((Label)row.Cells[3].FindControl("LblPrice")).Text);
                            double POTaxPrice    = Convert.ToDouble(((Label)row.Cells[3].FindControl("Lbltaxid")).Text);
                            double pototalamount = Convert.ToDouble(((Label)row.Cells[3].FindControl("LbltotalAmount")).Text);

                            string TxtInQuantity      = ((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text;
                            string TxtInPrice         = ((TextBox)row.Cells[4].FindControl("TxtInPrice")).Text;
                            double invoicetotalamount = Convert.ToDouble(((Label)row.Cells[3].FindControl("LblInvocietotalPrice")).Text);
                            string InvoiceTaxPrice    = ((TextBox)row.Cells[3].FindControl("txttaxid")).Text;

                            string loaction     = Txt_shippingAdress.Text.Trim();
                            string MainLocation = TxtPoLocation.Text;
                            result1 = ClsPurchaseInvoice.InsertPurchaseInvoicedetails1(invoiceid, Convert.ToInt32(asd), HidCatagory0, HidProduct0,
                                                                                       LblQuantity, LblPrice, POTaxPrice, pototalamount,
                                                                                       Convert.ToInt32(TxtInQuantity), Convert.ToDouble(TxtInPrice), InvoiceTaxPrice, invoicetotalamount, Convert.ToInt32(Session["Id"].ToString()), loaction, LblProduct, invoicedate, MainLocation, Convert.ToInt32(Session["int_LocationId"]));
                        }
                    }
                }
                else
                {
                    bool   Reject;
                    string HPOID = hidDetails_ID.Value;
                    Reject = ClsPurchaseInvoice.PurchaseOrderInvoiceQuantityReject(Convert.ToInt32(HPOID), ddlInvoiceApproval.SelectedValue);
                    if (Reject)
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('invoice Rejected...');</script>", false);
                    }
                }
                //if(ddlInvoiceApproval.SelectedValue=="1")
                //{
                string    pono        = TxtPoNo.Text;
                DataTable dtPOInvoice = new DataTable();
                //foreach (GridViewRow row in GvwPurchaseInvocie.Rows)
                //{
                //    if (row.RowType == DataControlRowType.DataRow)
                //    {
                //        string HidProduct0 = ((HiddenField)row.Cells[3].FindControl("HidProduct0")).Value;
                //        DataTable DT = ClsCheck.Get_PurchaseCheck(TxtPoNo.Text.Trim(), Convert.ToInt32(HidProduct0));
                //        int POQUANTITY = Convert.ToInt32(DT.Rows[0]["PO_QUANTITY"].ToString());
                //        int PURCHASEIN = Convert.ToInt32(DT.Rows[0]["PURCHASE_INVOICE"].ToString());
                //        int TxtInQuantity = Convert.ToInt32(((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text);

                // DataTable dtPOInvoice = new DataTable();

                dtPOInvoice.Columns.Add("Catagory", typeof(string));
                dtPOInvoice.Columns.Add("Product", typeof(string));
                dtPOInvoice.Columns.Add("POQuantity", typeof(string));
                dtPOInvoice.Columns.Add("POPrice", typeof(string));
                dtPOInvoice.Columns.Add("POTax", typeof(string));
                dtPOInvoice.Columns.Add("POTotalPrice", typeof(string));
                dtPOInvoice.Columns.Add("InvoicQuantity", typeof(string));
                dtPOInvoice.Columns.Add("InvoicePrice", typeof(string));
                dtPOInvoice.Columns.Add("InvoiceTax", typeof(string));
                dtPOInvoice.Columns.Add("InvoiceTotalPrice", typeof(string));

                foreach (GridViewRow gvRow in GvwPurchaseInvocie.Rows)
                {
                    DataRow drInvDet = dtPOInvoice.NewRow();
                    drInvDet["Catagory"]   = ((Label)gvRow.FindControl("lblCatagory")).Text;
                    drInvDet["Product"]    = ((Label)gvRow.FindControl("LblProduct")).Text;
                    drInvDet["POQuantity"] = ((Label)gvRow.FindControl("LblQuantity")).Text;
                    int PO_Quantity = Convert.ToInt32(((Label)gvRow.FindControl("LblQuantity")).Text);
                    drInvDet["POPrice"]        = ((Label)gvRow.FindControl("LblPrice")).Text;
                    drInvDet["POTax"]          = ((Label)gvRow.FindControl("Lbltaxid")).Text;
                    drInvDet["POTotalPrice"]   = ((Label)gvRow.FindControl("LbltotalAmount")).Text;
                    drInvDet["InvoicQuantity"] = ((TextBox)gvRow.FindControl("TxtInQuantity")).Text;
                    int InvoiceQuantity = Convert.ToInt32(((TextBox)gvRow.FindControl("TxtInQuantity")).Text);
                    drInvDet["InvoicePrice"]      = ((TextBox)gvRow.FindControl("TxtInPrice")).Text;
                    drInvDet["InvoiceTax"]        = ((TextBox)gvRow.FindControl("txttaxid")).Text;
                    drInvDet["InvoiceTotalPrice"] = ((Label)gvRow.FindControl("LblInvocietotalPrice")).Text;
                    dtPOInvoice.Rows.Add(drInvDet);
                }
                // int i = objclsinvc.PurchaseOrderInvoiceQuantityApproval_RejectStatusFromPOM(TxtPoNo.Text, TxtPoLocation.Text, TxtPoDate.Text, dtPOInvoice,ddlInvoiceApproval.SelectedValue,Txt_InvoiceNo.Text);
                // this.ClientScript.RegisterStartupScript(this.GetType(), "PopupScript", "<script type=text/javascript>alert('Check Invoice Quantity')</script>");

                // }
                // }
                int i = objclsinvc.PurchaseOrderInvoiceQuantityApproval_RejectStatusFromPOM(TxtPoNo.Text, TxtPoLocation.Text, TxtPoDate.Text, dtPOInvoice, ddlInvoiceApproval.SelectedValue, Txt_InvoiceNo.Text);

                // }

                Txt_InvoiceNo.Text   = "";
                Txt_InvoiceDate.Text = "";
                Txt_SubTotal.Text    = "0.00";

                TxtInTotalAmount.Text = "0.00";
                GetSalesManager();
                Panel1.Visible = false; Panel2.Visible = true; tbldate.Visible = true;
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Fill Invoice Number and Invoice Date...');</script>", false);
            }
        }
        catch (Exception ex)
        {
        }
    }
    protected void BtnGRNSave_Click(object sender, EventArgs e)
    {
        try
        {
            ClsPurchaseInvoice objclsinvc = new ClsPurchaseInvoice();
            if (Txt_InvoiceDate.Text != string.Empty && TxtLorryRcptNum.Text != string.Empty)
            {
                foreach (GridViewRow row in GvwPurchaseInvocie.Rows)
                {
                    if (((TextBox)row.FindControl("TxtInQuantity")).Text == "")
                    {
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Enter GRN Quantity.');</script>", false);
                        return;
                    }
                    if (((TextBox)row.FindControl("TxtInQuantity")).Text != "0")
                    {
                        if (((TextBox)row.FindControl("txtSupRefNo")).Text == "")
                        {
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Enter Supplier Reference Number.');</script>", false);
                            return;
                        }
                        else if (((TextBox)row.FindControl("txtSupRefDate")).Text == "")
                        {
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select Supplier Reference Date.');</script>", false);
                            return;
                        }
                    }
                    //else if (Txt_InvoiceDate.Text != "")
                    // {
                    DateTime GRNDate = Convert.ToDateTime(Txt_InvoiceDate.Text);

                    string TxtSupRefDate = ((TextBox)row.FindControl("txtSupRefDate")).Text;
                    if (TxtSupRefDate.ToString() != string.Empty || TxtSupRefDate.ToString() != "")
                    {
                        DateTime SupRefDate = Convert.ToDateTime(TxtSupRefDate);

                        if (SupRefDate > GRNDate)
                        {
                            // lblshowmsg.Text = "Supper reference date can't be greater than GRN date.";
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Supper reference date can not be greater than GRN date.');</script>", false);
                            //ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Supper reference date can't be greater than GRN date.');</script>", false);
                            ((TextBox)row.FindControl("txtSupRefDate")).Focus();
                            return;
                        }
                    }

                    //}
                    double TxtInPriceUpdate      = Convert.ToDouble(((TextBox)row.FindControl("TxtInPrice")).Text);
                    double TxtInTotalPriceUpdate = Convert.ToDouble(((TextBox)row.FindControl("TxtInTotalPrice")).Text);
                    Int32  TxtInQuantityUpdate   = Convert.ToInt32(((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text);
                    double Sum    = Convert.ToDouble((TxtInPriceUpdate * TxtInQuantityUpdate).ToString("0.00"));
                    double prvSum = Convert.ToDouble(TxtInTotalPriceUpdate.ToString("0.00"));
                    if (Sum != prvSum)
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "PopupScript", "<script type=text/javascript>alert('Please click on Update Button..')</script>");
                        Button BtnAdd = (Button)GvwPurchaseInvocie.FooterRow.FindControl("BtnAdd");
                        BtnAdd.Focus();
                        return;
                    }
                }
                //Check point
                //--t_purchase order detail and t_purchareinvoicedetail
                //string pono = TxtPoNo.Text;
                foreach (GridViewRow row in GvwPurchaseInvocie.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        string    HidCatagory0 = ((HiddenField)row.Cells[3].FindControl("HidCatagory0")).Value;
                        string    HidProduct0  = ((HiddenField)row.Cells[3].FindControl("HidProduct0")).Value;
                        DataTable DT           = ClsCheck.Get_PurchaseCheck(TxtPoNo.Text.Trim(), Convert.ToInt32(HidProduct0), Convert.ToInt32(HidCatagory0));
                        int       POQUANTITY   = Convert.ToInt32(((Label)row.Cells[2].FindControl("LblQuantity")).Text);

                        //int POQUANTITY = Convert.ToInt32(DT.Rows[0]["PO_QUANTITY"].ToString());
                        //int PURCHASEIN = Convert.ToInt32(DT.Rows[0]["PURCHASE_INVOICE"].ToString());
                        int TxtInQuantity = Convert.ToInt32(((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text);

                        if (POQUANTITY < TxtInQuantity)
                        {
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('GRN Quantity is greater than Purchase Quantity..');</script>", false);
                            return;
                        }
                    }
                }

                string POId = hidDetails_ID.Value;
                // string POId = ddlPONo.SelectedValue;
                DateTime PODATE   = Convert.ToDateTime(TxtPoDate.Text);
                string   ponumber = TxtPoNo.Text;

                int      GRNid;
                DateTime GRNdate     = DateTime.Now;
                string   totalAmount = "";
                GRNdate = Convert.ToDateTime(Txt_InvoiceDate.Text.Trim());
                //invoiceno = Txt_InvoiceNo.Text.Trim();
                totalAmount = Txt_SubTotal.Text.Trim();
                //showing alert if grn value is 0
                if (Txt_SubTotal.Text == "0" || Txt_SubTotal.Text == "0.0" || Txt_SubTotal.Text == "0.00")
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('GRN Total  Amount can not be 0...');</script>", false);
                    return;
                }

                //taxid = Convert.ToInt32(DrpTaxType.SelectedItem.Value);
                result2 = ClsGoodsReceiptNote.InsertPurchaseGRN(out GRNid, Convert.ToInt32(POId), ponumber, PODATE,
                                                                GRNdate, Convert.ToDouble(totalAmount), Convert.ToInt32(Session["Id"]), TxtLorryRcptNum.Text.Trim(), txtVehicleNum.Text.Trim(), txtAWBNum.Text.Trim());
                if (result2)
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('GRN Saved Successfully...');</script>", false);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('GRN Insertion Failed...');</script>", false);
                }

                DataTable dtGRN = new DataTable();
                dtGRN.Columns.Add("State", typeof(string));
                dtGRN.Columns.Add("Location", typeof(string));
                dtGRN.Columns.Add("Category", typeof(string));
                dtGRN.Columns.Add("Product", typeof(string));
                dtGRN.Columns.Add("RecvdQuantity", typeof(string));

                foreach (GridViewRow row in GvwPurchaseInvocie.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        string LblSlno       = ((Label)row.Cells[0].FindControl("LblSlno")).Text;
                        Int64  HidPODetId    = Convert.ToInt32(((HiddenField)row.Cells[2].FindControl("HdfPODETID")).Value);
                        string lblCatagory   = ((Label)row.Cells[1].FindControl("lblCatagory")).Text;
                        Int32  HidCatagory0  = Convert.ToInt32(((HiddenField)row.Cells[2].FindControl("HidCatagory0")).Value);
                        string LblProduct    = ((Label)row.Cells[3].FindControl("LblProduct")).Text;
                        Int32  HidProduct0   = Convert.ToInt32(((HiddenField)row.Cells[4].FindControl("HidProduct0")).Value);
                        Int32  LblQuantity   = Convert.ToInt32(((Label)row.Cells[3].FindControl("LblQuantity")).Text);
                        double LblPrice      = Convert.ToDouble(((Label)row.Cells[3].FindControl("LblPrice")).Text);
                        double POTaxPrice    = Convert.ToDouble(((Label)row.Cells[3].FindControl("Lbltaxid")).Text);
                        double pototalamount = Convert.ToDouble(((Label)row.Cells[3].FindControl("LbltotalAmount")).Text);

                        string TxtInQuantity      = ((TextBox)row.Cells[3].FindControl("TxtInQuantity")).Text;
                        string TxtInPrice         = ((TextBox)row.Cells[4].FindControl("TxtInPrice")).Text;
                        double invoicetotalamount = Convert.ToDouble(((Label)row.Cells[3].FindControl("LblInvocietotalPrice")).Text);
                        string InvoiceTaxPrice    = ((TextBox)row.Cells[3].FindControl("txttaxid")).Text;

                        string loaction     = TxtShippingAddress.Text.Trim();
                        string MainLocation = TxtPoLocation.Text;
                        //added by sita for getting supplier ref number and date as per the new changes.

                        string SupRefNo = ((TextBox)row.FindControl("txtSupRefNo")).Text;
                        // ((TextBox)row.Cells[3].FindControl("txtSupRefNo")).Text;
                        string   TxtSupRefDate = ((TextBox)row.FindControl("txtSupRefDate")).Text;
                        DateTime SupRefDate    = System.DateTime.Now;
                        if (TxtSupRefDate.ToString() != string.Empty)
                        {
                            SupRefDate = Convert.ToDateTime(TxtSupRefDate);
                        }
                        //((TextBox)row.Cells[3].FindControl("txtSupRefDate")).Text;
                        if (TxtInQuantity != "0")
                        {
                            result1 = ClsGoodsReceiptNote.Insert_Po_GRN_Details(GRNid, Convert.ToInt32(POId), HidCatagory0, HidProduct0,
                                                                                LblQuantity, LblPrice, POTaxPrice, pototalamount, Convert.ToInt32(TxtInQuantity), Convert.ToDouble(TxtInPrice),
                                                                                InvoiceTaxPrice, invoicetotalamount, Convert.ToInt32(Session["Id"].ToString()), loaction, LblProduct, GRNdate, MainLocation,
                                                                                Convert.ToInt32(Session["int_LocationId"]), HidPODetId, SupRefNo, SupRefDate);

                            DataRow drGRN = dtGRN.NewRow();
                            drGRN["State"]         = TxtPoSupplierState.Text;
                            drGRN["Location"]      = TxtPoLocation.Text;
                            drGRN["Category"]      = lblCatagory;
                            drGRN["Product"]       = LblProduct;
                            drGRN["RecvdQuantity"] = TxtInQuantity;
                            dtGRN.Rows.Add(drGRN);
                        }
                    }
                }
                if (dtGRN.Rows.Count > 0)
                {
                    ClsSalesOrder objclsSo       = new ClsSalesOrder();
                    int           SentMailResult = objclsSo.Send_Mail_GRN_RecivedQuantity_Details(dtGRN);
                }

                // Txt_InvoiceNo.Text = "";
                Txt_InvoiceDate.Text  = "";
                Txt_SubTotal.Text     = "0.00";
                txtAWBNum.Text        = "";
                TxtInTotalAmount.Text = "0.00";
                GetGeneratePoDetails();
                Panel1.Visible = false; Panel2.Visible = true; tbldate.Visible = true;
            }
            else
            {
                //if (Txt_InvoiceNo.Text == "")
                //{
                //    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Enter Invoice Number.');</script>", false);
                //    Txt_InvoiceNo.Focus();
                //    return;

                //}
                if (Txt_InvoiceDate.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select GRN Date.');</script>", false);
                    Txt_InvoiceDate.Focus();
                    return;
                }

                //if (Txt_InvoiceDate.Text != "")
                //{
                //    DateTime PODate = Convert.ToDateTime(TxtPoDate.Text);
                //    DateTime PO_date = Convert.ToDateTime(PODate.ToString("dd/MM/yyyy"));
                //    DateTime InvoiceDate = Convert.ToDateTime(Txt_InvoiceDate.Text);
                //    DateTime Invoice_Date = Convert.ToDateTime(InvoiceDate.ToString("dd/MM/yyyy"));
                //    if (PO_date > Invoice_Date)
                //    {
                //        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Invoice Date Should be Greater Than PO Date.');</script>", false);
                //        TxtPoDate.Focus();
                //        return;
                //    }
                //}
                if (TxtLorryRcptNum.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Enter Lorry receipt number.');</script>", false);
                    TxtLorryRcptNum.Focus();
                    return;
                }
                // ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Fill Invoice Number and Invoice Date...');</script>", false);
            }
        }
        catch (Exception ex)
        {
        }
    }
Esempio n. 12
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        try
        {
            if (ddlPonumber.SelectedIndex != 0)
            {
                string MainCategory = ClsPurchaseInvoice.Get_MainCategory_BasedOn_POID(Convert.ToInt64(ddlPonumber.SelectedValue.ToString()));
                if (MainCategory != "Support")
                {
                    Panel1.Visible = true;
                    value          = Convert.ToInt32(ddlPonumber.SelectedValue.ToString());
                    if (value != -1)
                    {
                        DataTable dt = ClsReportPurchaseOrder.Report_PurchaseOrder(value);
                        lbl_Ponumber.Text     = dt.Rows[0]["PO Number"].ToString();
                        lbl_PoDate.Text       = Convert.ToDateTime(dt.Rows[0]["PO Date"]).ToString("dd-MM-yyyy");
                        lbl_PO_RaisedTO.Text  = dt.Rows[0]["PO_Raise_TO"].ToString();
                        lbl_Bill_Address.Text = dt.Rows[0]["BillingAddress"].ToString();
                        lbl_Ship_Address.Text = dt.Rows[0]["ShippingAddress"].ToString();
                        //lbl_Footer_Address1.Text = dt.Rows[0]["BillingAddress"].ToString();
                        lbl_Term4.Text  = "4. Warranty :" + dt.Rows[0]["Warranty"].ToString();
                        lblBillGST.Text = dt.Rows[0]["GST"].ToString();
                        lblBillPAN.Text = dt.Rows[0]["PAN"].ToString();
                        lblSPA.Text     = dt.Rows[0]["SPANumber"].ToString();
                        // lblShipGST.Text= dt.Rows[0]["GST"].ToString();
                        lblShipPAN.Text = dt.Rows[0]["PAN"].ToString();

                        DataTable DT1        = ClsPurchaseInvoice.Get_PurchaseOrderForInvoice(value);
                        int       CategoryID = 0;
                        //foreach (DataRow row in DT1.Rows)
                        //{
                        //for (int i = 0; i < DT1.Rows.Count - 1; i++)
                        //{
                        //    CategoryID = Convert.ToInt32(DT1.Rows[i]["catagoryid"].ToString());

                        //if (CategoryID == 33)
                        //{
                        //GetSalesManager();
                        GetSalesManagerAMC1();
                        //lbl_Term3.Text = "";
                        //}
                        //else
                        //{
                        //    GetSalesManager();

                        //}
                        // }
                        //if (CategoryID == 33)
                        //{

                        //foreach (GridViewRow row in GridView1.Rows)
                        //{
                        //    foreach (TableCell cell in row.Cells)
                        //    {
                        //        row.Cells[0].Width = 10;
                        //    }
                        //}


                        Response.ContentType = "application/pdf";
                        Response.AddHeader("content-disposition", "attachment;filename=PO.pdf");
                        Response.Cache.SetCacheability(HttpCacheability.NoCache);
                        StringWriter   sw = new StringWriter();
                        HtmlTextWriter hw = new HtmlTextWriter(sw);
                        GridView1.HeaderRow.Style.Add("width", "10%");
                        GridView1.HeaderRow.Style.Add("font-size", "10px");
                        GridView1.Style.Add("font-size", "8px");
                        Panel1.RenderControl(hw);

                        StringReader sr = new StringReader(sw.ToString());

                        Document   pdfDoc     = new Document(PageSize.A4, 20f, 20f, 100f, 100f);
                        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                        PdfWriter  pdfWriter  = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
                        pdfWriter.PageEvent = new Comman.ITextEvents();
                        pdfDoc.Open();

                        htmlparser.Parse(sr);
                        pdfDoc.Close();
                        Response.Write(pdfDoc);
                        // Response.End();
                        HttpContext.Current.Response.Flush();
                        HttpContext.Current.Response.SuppressContent = true;
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        Panel1.Visible = false;
                        GetMasterList();
                        #region old code
                        //}
                        //else
                        //{
                        //    Response.ContentType = "application/pdf";
                        //    Response.AddHeader("content-disposition", "attachment;filename=PO.pdf");
                        //    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                        //    StringWriter sw = new StringWriter();
                        //    HtmlTextWriter hw = new HtmlTextWriter(sw);
                        //    GvwSaleseOrderDetails.HeaderRow.Style.Add("width", "10%");
                        //    GvwSaleseOrderDetails.HeaderRow.Style.Add("font-size", "10px");
                        //    GvwSaleseOrderDetails.Style.Add("font-size", "8px");
                        //    Panel1.RenderControl(hw);

                        //    StringReader sr = new StringReader(sw.ToString());
                        //    Document pdfDoc = new Document(PageSize.A4, 20f, 20f, 20f, 20f);
                        //    HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                        //    PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
                        //    pdfDoc.Open();
                        //    htmlparser.Parse(sr);
                        //    pdfDoc.Close();
                        //    Response.Write(pdfDoc);
                        //    // Response.End();
                        //    HttpContext.Current.Response.Flush();
                        //    HttpContext.Current.Response.SuppressContent = true;
                        //    HttpContext.Current.ApplicationInstance.CompleteRequest();
                        //    Panel1.Visible = false;
                        //    GetMasterList();
                        //}
                        #endregion
                    }
                    else
                    {
                        Panel1.Visible = false;
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select PO Number.');</script>", false);
                    }
                }
                else
                {
                    Panel2.Visible = true;
                    value          = Convert.ToInt32(ddlPonumber.SelectedValue.ToString());
                    if (value != -1)
                    {
                        DataTable dt = ClsReportPurchaseOrder.Report_PurchaseOrder(value);
                        lbl_PonumberSupport.Text      = dt.Rows[0]["PO Number"].ToString();
                        lbl_PoDateSupport.Text        = Convert.ToDateTime(dt.Rows[0]["PO Date"]).ToString("dd-MM-yyyy");
                        lbl_PO_RaisedTO.Text          = dt.Rows[0]["PO_Raise_TO"].ToString();
                        lbl_Bill_Address_Support.Text = dt.Rows[0]["BillingAddress"].ToString();
                        lbl_Ship_Address_Support.Text = dt.Rows[0]["ShippingAddress"].ToString();
                        lblSPA.Text       = dt.Rows[0]["SPANumber"].ToString();
                        lblSupBilGST.Text = dt.Rows[0]["GST"].ToString();
                        lblSupBilPAN.Text = dt.Rows[0]["PAN"].ToString();

                        //lbl_Footer_Address1.Text = dt.Rows[0]["BillingAddress"].ToString();

                        DataTable DT1 = ClsPurchaseInvoice.Get_PurchaseOrderForInvoice(value);
                        foreach (DataRow row in DT1.Rows)
                        {
                            int CategoryID = Convert.ToInt32(DT1.Rows[0]["catagoryid"].ToString());

                            if (CategoryID == 5 || CategoryID == 20 || CategoryID == 30 || CategoryID == 31 || CategoryID == 32 || CategoryID == 33 || CategoryID == 42)
                            {
                                //GetSalesManagerSupport();
                                GetSalesManagerAMC();

                                lbl_Term3.Text = "";
                            }
                            else
                            {
                                GetSalesManagerSupport();
                            }
                        }
                        Response.ContentType = "application/pdf";
                        Response.AddHeader("content-disposition", "attachment;filename=PO.pdf");
                        Response.Cache.SetCacheability(HttpCacheability.NoCache);
                        StringWriter   sw = new StringWriter();
                        HtmlTextWriter hw = new HtmlTextWriter(sw);
                        GridView3.HeaderRow.Style.Add("width", "10%");
                        GridView3.HeaderRow.Style.Add("font-size", "10px");
                        GridView3.Style.Add("font-size", "8px");

                        Panel2.RenderControl(hw);

                        StringReader sr         = new StringReader(sw.ToString());
                        Document     pdfDoc     = new Document(PageSize.A4, 20f, 20f, 130f, 100f);
                        HTMLWorker   htmlparser = new HTMLWorker(pdfDoc);
                        PdfWriter    pdfWriter  = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
                        pdfWriter.PageEvent = new Comman.ITextEvents();
                        pdfDoc.Open();
                        htmlparser.Parse(sr);
                        pdfDoc.Close();
                        Response.Write(pdfDoc);
                        // Response.End();
                        HttpContext.Current.Response.Flush();
                        HttpContext.Current.Response.SuppressContent = true;
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        Panel2.Visible = false;
                        GetMasterList();
                    }
                    else
                    {
                        Panel2.Visible = false;
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select PO Number.');</script>", false);
                    }
                }
            }
            else
            {
                Panel1.Visible = false;
                ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select PO Number.');</script>", false);
            }
        }
        catch (Exception ex)
        {
        }
        //ddlPonumber.SelectedItem.Value = "-1";
    }