public void AddBillDetails(tbl_BillDetails objBillDetails) { try { objSKSEntities = new SKSEntities(); objSKSEntities.tbl_BillDetails.Add(objBillDetails); objSKSEntities.SaveChanges(); } catch (Exception ex) { throw ex; } finally { objSKSEntities = null; } }
protected void btnGenerateBill_Click(object sender, EventArgs e) { try { if (gvBillItemDetails.Rows.Count > 0) { objBillMaster = new tbl_BillMaster(); objBillMaster.FK_BillingCustomerID = Convert.ToInt32(hdnIsNewBillingCustomer.Value); objBillMaster.InvoiceDate = Convert.ToDateTime(DateTime.Now.ToString()); objBillMaster.FK_ShippingCustomerID = Convert.ToInt32(hdnIsNewShippingCustomer.Value); objBillMaster.InvoiceTotalAmount = Convert.ToDecimal(txtInvoiceTotal.Text.Trim()); objBillMaster.TotalDiscountonInvoice = Convert.ToDecimal(lblSummarytotaldiscount.Text); objBillMaster.TotalCollectedAmount = Convert.ToDecimal(txtTotalCollectedAmount.Value.ToString().Trim()); objBillMaster.LoadingnPackingCharges = Convert.ToDecimal(txtLOadingnPackingCharges.Text = string.IsNullOrEmpty(txtLOadingnPackingCharges.Text.Trim()) ? "0" : txtLOadingnPackingCharges.Text.Trim()); // objBillMaster.InsuranceCharges = Convert.ToDecimal(txtInsuranceCharges.Text.Trim()); objBillMaster.InsuranceCharges = Convert.ToDecimal(txtInsuranceCharges.Text = string.IsNullOrEmpty(txtInsuranceCharges.Text.Trim()) ? "0" : txtInsuranceCharges.Text.Trim()); // objBillMaster.OtherCharges = Convert.ToDecimal(txtOtherCharges.Text.Trim()); objBillMaster.OtherCharges = Convert.ToDecimal(txtOtherCharges.Text = string.IsNullOrEmpty(txtOtherCharges.Text.Trim()) ? "0" : txtOtherCharges.Text.Trim()); objBillMaster.TransportationMode = ddlTransportationType.SelectedItem.Value.ToString(); objBillMaster.VehivleNumber = txtVehicalNumber.Text.Trim(); // objBillMaster.FreightCharges = Convert.ToDecimal(txtFreightCharges.Text.Trim()); objBillMaster.FreightCharges = Convert.ToDecimal(txtFreightCharges.Text = string.IsNullOrEmpty(txtFreightCharges.Text.Trim()) ? "0" : txtFreightCharges.Text.Trim()); if (Convert.ToInt16(ddlTransportationType.SelectedItem.Value) > 0) { objBillMaster.DateNSupplyofTime = Convert.ToDateTime(DateTime.Now.ToString()); } objBillMaster.FinancialYear = get_FinancialYear(); objBillMaster.PlaceofSupply = txtPLaceofSupply.Text.Trim(); objBillMaster.GUID = hdnGUID.Value.ToString(); objBillMaster.InvoiceStatus = "Success"; objBillMaster.IsActive = true; objBillMaster.IsDeleted = false; objBillMaster.CreatedBy = "Admin"; objBillMaster.CreatedOn = Convert.ToDateTime(DateTime.Now.ToString()); objBillMaster.TotalCGSTAmount = Convert.ToDecimal(lblSummaryCGSTAmount.Text); objBillMaster.TotalSGSTAmount = Convert.ToDecimal(lblSummarySGSTAmount.Text); objBillMaster.TotalProductQuantity = Convert.ToInt32(lblSummaryTotalQuantity.Text); objBusinessFacadLayer = new BusinessFacadLayer(); intBillInvoiceNumber = objBusinessFacadLayer.CreateInvoicenGenerateInvoiceNo(objBillMaster); if (intBillInvoiceNumber > 0) { objBillDetails = new tbl_BillDetails(); for (int i = 0; i < gvBillItemDetails.Rows.Count; i++) { objBillDetails.FK_BillMasterID = intBillInvoiceNumber; objBillDetails.CompanyID = Convert.ToInt32(gvBillItemDetails.Rows[i].Cells[16].Text.ToString()); objBillDetails.ProductID = Convert.ToInt32(gvBillItemDetails.Rows[i].Cells[17].Text.ToString()); objBillDetails.HSNNo = gvBillItemDetails.Rows[i].Cells[5].Text.ToString(); objBillDetails.Qnty = Convert.ToInt32(gvBillItemDetails.Rows[i].Cells[6].Text.ToString()); objBillDetails.Rate = Convert.ToDecimal(gvBillItemDetails.Rows[i].Cells[8].Text.ToString()); objBillDetails.UOM = gvBillItemDetails.Rows[i].Cells[7].Text.ToString(); objBillDetails.Total = Convert.ToDecimal(gvBillItemDetails.Rows[i].Cells[9].Text.ToString()); objBillDetails.Discount = Convert.ToDecimal(gvBillItemDetails.Rows[i].Cells[10].Text.ToString()); objBillDetails.TaxableValue = Convert.ToDecimal(gvBillItemDetails.Rows[i].Cells[11].Text.ToString()); objBillDetails.SGSTRate = Convert.ToDecimal(gvBillItemDetails.Rows[i].Cells[12].Text.ToString()); objBillDetails.SGSTValue = Convert.ToDecimal(gvBillItemDetails.Rows[i].Cells[13].Text.ToString()); objBillDetails.CGSTRate = Convert.ToDecimal(gvBillItemDetails.Rows[i].Cells[14].Text.ToString()); objBillDetails.CGSTValue = Convert.ToDecimal(gvBillItemDetails.Rows[i].Cells[15].Text.ToString()); objBillDetails.GUID = hdnGUID.Value.ToString(); objBillDetails.IsActive = true; objBillDetails.IsDeleted = false; objBillDetails.CreatedBy = "Admin"; objBillDetails.CreatedOn = Convert.ToDateTime(DateTime.Now.ToString()); objBusinessFacadLayer.AddBillDetails(objBillDetails); } } else { } Response.Redirect("frmTaxInvoice.aspx", false); } else { } } catch (Exception ex) { } finally { objBusinessFacadLayer = null; } }