//protected void GvwSalesRegister_RowCommand(object sender, GridViewCommandEventArgs e) //{ // try // { // if (e.CommandName == "Edit1") // { // TxtLorryRcptNum.Text = ""; // Txt_InvoiceDate.Text = ""; // Panel1.Visible = true; // Panel2.Visible = false; // tbldate.Visible = false; // int index = Convert.ToInt32(e.CommandArgument); // GridViewRow row = GvwSalesRegister.Rows[index]; // Label lbl = (Label)row.FindControl("hidennID"); // // hidDetails_ID.Value = e.CommandArgument.ToString(); // string ID = lbl.Text.Trim(); // hidDetails_ID.Value = ID; // DataTable dtItem = (DataTable)ViewState["Data"]; // DataRow[] drModel = dtItem.Select("PO_ID='" + ID + "'"); // DataTable dtNew = new DataTable(); // dtNew = dtItem.Clone(); // if (drModel.Length > 0) // { // foreach (DataRow dr in drModel) // { // dtNew.ImportRow(dr); // } // dtNew.AcceptChanges(); // int supp_id = Convert.ToInt32(dtNew.Rows[0]["suppilerid"]); // DataTable dtsup = BusinessLogicLayer.ClsSalesManagerChecking.get_reversecharges(supp_id); // TxtPoDate.Text = dtNew.Rows[0]["PO_Date"].ToString(); // TxtPoNo.Text = dtNew.Rows[0]["PO_Number"].ToString(); // TxtPoLocation.Text = dtNew.Rows[0]["Location"].ToString(); // TxtPoSupplier.Text = dtNew.Rows[0]["Supplier"].ToString(); // // TxtTotalAmount.Text = dtNew.Rows[0]["PO_NetAmount"].ToString(); // Txt_SubTotal.Text = dtNew.Rows[0]["PO_NetAmount"].ToString(); // TxtInTotalAmount.Text = dtNew.Rows[0]["PO_NetAmount"].ToString(); // TxtType.Text = dtNew.Rows[0]["M_CategoryName"].ToString(); // txt_hsnac.Text = dtNew.Rows[0]["HSN_SAC_NUM"].ToString(); // TxtPurchaseType.Text= dtNew.Rows[0]["Purchase_Type"].ToString(); // if (TxtType.Text.Trim() == "Service" || TxtType.Text.Trim() == "Support" || TxtType.Text.Trim() == "Rental") // { // lbl_hsnac.Text = "SAN Code"; // } // else // { // lbl_hsnac.Text = "HSN Code"; // } // if (TxtType.Text.Trim() == "Scanners" || TxtType.Text.Trim() == "Support" || TxtType.Text.Trim() == "Software") // { // TrWarranty.Visible = true; // TxtWarranty.Text = dtNew.Rows[0]["Warranty"].ToString(); // } // else // { // TrWarranty.Visible = false; // } // if (TxtPoSupplier.Text.Trim() == "Others") // { // TrVendor.Visible = true; // TxtVendor.Text = dtNew.Rows[0]["VendorName"].ToString(); // } // else // { // TrVendor.Visible = false; // } // TxtBillingAddress.Text = dtNew.Rows[0]["BillingAddress"].ToString(); // TxtShippingAddress.Text = dtNew.Rows[0]["ShippingAddress"].ToString(); // int_LocationId = Convert.ToInt32(dtNew.Rows[0]["locationID"].ToString()); // Session["int_LocationId"] = int_LocationId; // TxtPoSupplierState.Text= dtNew.Rows[0]["State_Name"].ToString(); // TxtGST.Text= dtNew.Rows[0]["Sup_Vat_Cst"].ToString(); // txtPaymentterms.Text= dtNew.Rows[0]["Sup_PaymentTerms"].ToString(); // txtTermsOfDelivery.Text = dtNew.Rows[0]["TermOfDelv"].ToString(); // TxtSupplierState.Text= dtNew.Rows[0]["Sup_StateName"].ToString(); // txtrevers.Text = dtsup.Rows[0]["Reverse_Charge"].ToString(); // TxtPanNum.Text = dtsup.Rows[0]["PAN"].ToString(); // } // PoDetails(Convert.ToInt64(ID)); // AddNewGridRow1(); // GetGeneratePoDetails(); // ViewState["PageINdex"] = GvwSalesRegister.PageIndex; // } // } // catch (Exception ex) // { } //} private void PoDetails(Int64 id) { DataTable ds = new DataTable(); ds = ClsGoodsReceiptNote.Get_PurchaseOrderDetailsForGRN(id); GvwPurchaseInvocie.DataSource = ds; GvwPurchaseInvocie.DataBind(); }
private void GetGeneratePoDetails() { DataTable ds = new DataTable(); try { ds = ClsGoodsReceiptNote.Get_PurchaseOrderForGRN(Convert.ToDateTime(Txt_FromDate.Text.Trim()), Convert.ToDateTime(Txt_ToDate.Text.Trim())); if (ds.Rows.Count > 0) { lblMsg.Text = ""; //Start Adding by sita on 28-07-2017 as per the requirement by suhas trddl.Visible = true; ddlPONo.Items.Clear(); ddlPONo.DataSource = ds; ddlPONo.DataTextField = "PO_Number"; ddlPONo.DataValueField = "PO_ID"; ddlPONo.DataBind(); ddlPONo.Items.Insert(0, new ListItem("--Select PO Number--", "0")); //end Adding by sita on 28-07-2017 //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 = ClsGoodsReceiptNote.GetPartialdataBasedOnPONumForGRN(ds.Rows[i]["PO_Number"].ToString()); // if (dtPartial.Rows.Count > 0) // { // GvwSalesRegister.Rows[i].Cells[1].BackColor = System.Drawing.Color.Yellow; // } //} } else { trddl.Visible = false; lblMsg.Text = "No Records Found"; // ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('NO Data Found...');</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) { } }