public void SalesMasterEdit(SalesMasterInfo salesmasterinfo) { try { SPSalesMaster.SalesMasterEdit(salesmasterinfo); } catch (Exception ex) { MessageBox.Show("CB:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public SalesMasterInfo SalesMasterView(decimal salesMasterId) { try { InfoSalesMaster = SPSalesMaster.SalesMasterView(salesMasterId); } catch (Exception ex) { MessageBox.Show("CB:4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(InfoSalesMaster); }
public decimal SalesMasterAdd(SalesMasterInfo salesmasterinfo) { decimal decCompanyId = 0; try { decCompanyId = SPSalesMaster.SalesMasterAdd(salesmasterinfo); } catch (Exception ex) { MessageBox.Show("CB:9" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(decCompanyId); }
/// <summary> /// Save function /// </summary> public void SaveFunction() { StockPostingInfo infoStockPosting = new StockPostingInfo(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); SalesDetailsInfo InfoSalesDetails = new SalesDetailsInfo(); StockPostingBll BllStockPosting = new StockPostingBll(); AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo(); AditionalCostBll bllAditionalCost = new AditionalCostBll(); SalesBillTaxInfo infoSalesBillTax = new SalesBillTaxInfo(); SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll(); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); try { InfoSalesMaster.AdditionalCost = Convert.ToDecimal(lblLedgerTotalAmount.Text); InfoSalesMaster.BillDiscount = Convert.ToDecimal(txtBillDiscount.Text.Trim()); InfoSalesMaster.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.Trim().ToString()); InfoSalesMaster.CustomerName = txtCustomer.Text.Trim(); InfoSalesMaster.Date = Convert.ToDateTime(txtDate.Text.ToString()); InfoSalesMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); InfoSalesMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); InfoSalesMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoSalesMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text.Trim()); InfoSalesMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); InfoSalesMaster.VoucherTypeId = DecSalesInvoiceVoucherTypeId; if (isAutomatic) { InfoSalesMaster.InvoiceNo = txtInvoiceNo.Text.Trim(); InfoSalesMaster.VoucherNo = strVoucherNo; InfoSalesMaster.SuffixPrefixId = decSalseInvoiceSuffixPrefixId; } else { InfoSalesMaster.InvoiceNo = txtInvoiceNo.Text.Trim(); InfoSalesMaster.VoucherNo = strVoucherNo; InfoSalesMaster.SuffixPrefixId = 0; } if (cmbSalesMode.Text == "Against SalesOrder") { InfoSalesMaster.OrderMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()); } else { InfoSalesMaster.OrderMasterId = 0; } if (cmbSalesMode.Text == "Against Delivery Note") { InfoSalesMaster.DeliveryNoteMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()); } else { InfoSalesMaster.DeliveryNoteMasterId = 0; } if (cmbSalesMode.Text == "Against Quotation") { InfoSalesMaster.QuotationMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()); } else { InfoSalesMaster.QuotationMasterId = 0; } InfoSalesMaster.Narration = txtNarration.Text.Trim(); InfoSalesMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); InfoSalesMaster.SalesAccount = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString()); InfoSalesMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text.Trim()); if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { InfoSalesMaster.TaxAmount = Convert.ToDecimal(lblTaxTotalAmount.Text.Trim()); } else { InfoSalesMaster.TaxAmount = 0; } InfoSalesMaster.UserId = PublicVariables._decCurrentUserId; InfoSalesMaster.LrNo = txtVehicleNo.Text; InfoSalesMaster.TransportationCompany = txtTransportCompany.Text.Trim(); InfoSalesMaster.POS = false; InfoSalesMaster.CounterId = 0; InfoSalesMaster.ExtraDate = DateTime.Now; InfoSalesMaster.Extra1 = string.Empty; InfoSalesMaster.Extra2 = string.Empty; decimal decSalesMasterId = BllSalesInvoice.SalesMasterAdd(InfoSalesMaster); int inRowCount = dgvSalesInvoice.RowCount; InfoSalesDetails.SalesMasterId = decSalesMasterId; InfoSalesDetails.ExtraDate = DateTime.Now; InfoSalesDetails.Extra1 = string.Empty; InfoSalesDetails.Extra2 = string.Empty; string strAgainstInvoiceN0 = txtInvoiceNo.Text.Trim(); for (int inI = 0; inI < inRowCount - 1; inI++) { if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductName"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductName"].Value.ToString() != string.Empty) { if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty) { if (cmbSalesMode.Text == "Against SalesOrder") { InfoSalesDetails.OrderDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSISalesOrderDetailsId"].Value.ToString()); } else { InfoSalesDetails.OrderDetailsId = 0; } if (cmbSalesMode.Text == "Against Delivery Note") { InfoSalesDetails.DeliveryNoteDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString()); } else { InfoSalesDetails.DeliveryNoteDetailsId = 0; } if (cmbSalesMode.Text == "Against Quotation") { InfoSalesDetails.QuotationDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value.ToString()); } else { InfoSalesDetails.QuotationDetailsId = 0; } InfoSalesDetails.SlNo = Convert.ToInt32(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSlno"].Value.ToString()); InfoSalesDetails.ProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()); InfoSalesDetails.Qty = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString()); InfoSalesDetails.Rate = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceRate"].Value.ToString()); InfoSalesDetails.UnitId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString()); InfoSalesDetails.UnitConversionId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value.ToString()); InfoSalesDetails.Discount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value.ToString()); InfoSalesDetails.BatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString()); if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString() != string.Empty) { InfoSalesDetails.GodownId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()); } else { InfoSalesDetails.GodownId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString() != string.Empty) { InfoSalesDetails.RackId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString()); } else { InfoSalesDetails.RackId = 0; } if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { InfoSalesDetails.TaxId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceTaxName"].Value.ToString()); InfoSalesDetails.TaxAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceTaxAmount"].Value.ToString()); } else { InfoSalesDetails.TaxId = 1; InfoSalesDetails.TaxAmount = 0; } InfoSalesDetails.GrossAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceGrossValue"].Value.ToString()); InfoSalesDetails.NetAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceNetAmount"].Value.ToString()); InfoSalesDetails.Amount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceAmount"].Value.ToString()); BllSalesInvoice.SalesDetailsAdd(InfoSalesDetails); infoStockPosting.Date = Convert.ToDateTime(txtDate.Text.Trim().ToString()); infoStockPosting.ProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()); infoStockPosting.BatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString()); infoStockPosting.UnitId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString()); if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString() != string.Empty) { infoStockPosting.GodownId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()); } else { infoStockPosting.GodownId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString() != string.Empty) { infoStockPosting.RackId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString()); } else { infoStockPosting.RackId = 0; } infoStockPosting.Rate = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceRate"].Value.ToString()); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.ExtraDate = DateTime.Now; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value != null) { if (Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString()) != 0) { infoStockPosting.InwardQty = InfoSalesDetails.Qty / bllUnitConvertion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId); infoStockPosting.OutwardQty = 0; infoStockPosting.VoucherNo = strVoucherNoTostockPost; infoStockPosting.AgainstVoucherNo = strVoucherNo; infoStockPosting.InvoiceNo = strInvoiceNoTostockPost; infoStockPosting.AgainstInvoiceNo = strAgainstInvoiceN0; infoStockPosting.VoucherTypeId = decVouchertypeIdTostockPost; infoStockPosting.AgainstVoucherTypeId = DecSalesInvoiceVoucherTypeId; BllStockPosting.StockPostingAdd(infoStockPosting); } } infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = InfoSalesDetails.Qty / bllUnitConvertion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId); infoStockPosting.VoucherNo = InfoSalesMaster.VoucherNo; ; infoStockPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoStockPosting.InvoiceNo = InfoSalesMaster.InvoiceNo; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; BllStockPosting.StockPostingAdd(infoStockPosting); } } } if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { int inTaxRowCount = dgvSalesInvoiceTax.RowCount; infoSalesBillTax.SalesMasterId = decSalesMasterId; infoSalesBillTax.ExtraDate = DateTime.Now; infoSalesBillTax.Extra1 = string.Empty; infoSalesBillTax.Extra2 = string.Empty; for (int inI = 0; inI < inTaxRowCount; inI++) { if (dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxId"].Value != null && dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxId"].Value.ToString() != string.Empty) { if (dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxAmount"].Value != null && dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxAmount"].Value.ToString() != string.Empty) { decimal decAmount = Convert.ToDecimal(dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxAmount"].Value); if (decAmount > 0) { infoSalesBillTax.TaxId = Convert.ToInt32(dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxId"].Value.ToString()); infoSalesBillTax.TaxAmount = Convert.ToDecimal(dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxAmount"].Value.ToString()); BllSalesInvoice.SalesBillTaxAdd(infoSalesBillTax); } } } } } int inAddRowCount = dgvSalesInvoiceLedger.RowCount; infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.ExtraDate = DateTime.Now; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; for (int inI = 0; inI < inAddRowCount; inI++) { if (dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value != null && dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString() != string.Empty) { if (dgvSalesInvoiceLedger.Rows[inI].Cells["dgvtxtAdditionalCoastledgerAmount"].Value != null && dgvSalesInvoiceLedger.Rows[inI].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString() != string.Empty) { infoAdditionalCost.LedgerId = Convert.ToInt32(dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString()); if (!cmbCashOrbank.Visible) { infoAdditionalCost.Debit = 0; infoAdditionalCost.Credit = Convert.ToDecimal(dgvSalesInvoiceLedger.Rows[inI].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); } else { infoAdditionalCost.Debit = Convert.ToDecimal(dgvSalesInvoiceLedger.Rows[inI].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); infoAdditionalCost.Credit = 0; } bllAditionalCost.AdditionalCostAdd(infoAdditionalCost); } } } if (!cmbCashOrbank.Visible) { decimal decCAshOrBankId = 0; decCAshOrBankId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); decimal decTotalAddAmount = Convert.ToDecimal(lblLedgerTotalAmount.Text.Trim().ToString()); if (decTotalAddAmount > 0) { infoAdditionalCost.Debit = decTotalAddAmount; infoAdditionalCost.Credit = 0; infoAdditionalCost.LedgerId = decCAshOrBankId; infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.ExtraDate = DateTime.Now; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; bllAditionalCost.AdditionalCostAdd(infoAdditionalCost); } } else { if (cmbCashOrbank.Visible) { decimal decCAshOrBankId = 0; decCAshOrBankId = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString()); decimal decTotalAddAmount = Convert.ToDecimal(lblLedgerTotalAmount.Text.Trim().ToString()); if (decTotalAddAmount > 0) { infoAdditionalCost.Debit = 0; infoAdditionalCost.Credit = decTotalAddAmount; infoAdditionalCost.LedgerId = decCAshOrBankId; infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.ExtraDate = DateTime.Now; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; bllAditionalCost.AdditionalCostAdd(infoAdditionalCost); } } } ledgerPostingAdd(); if (BllSalesInvoice.SalesInvoiceInvoicePartyCheckEnableBillByBillOrNot(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()))) { partyBalanceAdd(); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked == true) { SettingsBll BllSettings = new SettingsBll(); if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesMasterId); } else { Print(decSalesMasterId); } } Clear(); } catch (Exception ex) { MessageBox.Show("SI: 70" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Print function in crystal report /// </summary> /// <param name="decSalesMasterId"></param> public void Print(decimal decSalesMasterId) { SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); try { DataSet dsSalesInvoice = BllSalesInvoice.salesInvoicePrintAfterSave(decSalesMasterId, 1, InfoSalesMaster.OrderMasterId, InfoSalesMaster.DeliveryNoteMasterId, InfoSalesMaster.QuotationMasterId); frmReport frmReport = new frmReport(); frmReport.MdiParent = formMDI.MDIObj; frmReport.SalesInvoicePrinting(dsSalesInvoice); } catch (Exception ex) { MessageBox.Show("SI: 73" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Fill function for edit /// </summary> public void SalesInvoiceDetailsEditFill() { //SalesMasterSP spSalesMaster = new SalesMasterSP(); //SalesDetailsSP spSalesDetails = new SalesDetailsSP(); PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); SalesDetailsInfo InfoSalesDetails = new SalesDetailsInfo(); StockPostingInfo infoStockPosting = new StockPostingInfo(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); StockPostingBll BllStockPosting = new StockPostingBll(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo(); AditionalCostBll bllAditionalCost = new AditionalCostBll(); SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll(); SalesBillTaxInfo infoSalesBillTax = new SalesBillTaxInfo(); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); try { string strAgainstInvoiceN0 = txtInvoiceNo.Text.Trim(); for (int inI = 0; inI < dgvSalesInvoice.Rows.Count - 1; inI++) { decimal decRefStatus = BllSalesInvoice.SalesInvoiceReferenceCheckForEdit(decSalesInvoiceIdToEdit); if (decRefStatus != 0) { dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductCode"].ReadOnly = true; dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductName"].ReadOnly = true; dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceBarcode"].ReadOnly = true; dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].ReadOnly = true; dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].ReadOnly = true; } if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value == null || dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString() == string.Empty || dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString() == "0") // here check the row added or editing current row { InfoSalesDetails.SalesMasterId = decSalesInvoiceIdToEdit; InfoSalesDetails.ExtraDate = DateTime.Now; InfoSalesDetails.Extra1 = string.Empty; InfoSalesDetails.Extra2 = string.Empty; if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductName"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductName"].Value.ToString() != string.Empty) { if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty) { if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSISalesOrderDetailsId"].Value != null) { InfoSalesDetails.OrderDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSISalesOrderDetailsId"].Value.ToString()); } else { InfoSalesDetails.OrderDetailsId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value != null) { InfoSalesDetails.DeliveryNoteDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString()); } else { InfoSalesDetails.DeliveryNoteDetailsId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value != null) { InfoSalesDetails.QuotationDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value.ToString()); } else { InfoSalesDetails.QuotationDetailsId = 0; } InfoSalesDetails.SlNo = Convert.ToInt32(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSlno"].Value.ToString()); InfoSalesDetails.ProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()); decimal decQty = BllSalesInvoice.SalesInvoiceQuantityDetailsAgainstSalesReturn(DecSalesInvoiceVoucherTypeId, strVoucherNo); if (Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString()) < decQty) { dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value = 0; decRefStatus = 1; MessageBox.Show("Quantity should be greater than " + decQty, "Open_Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvSalesInvoice.Focus(); } else { InfoSalesDetails.Qty = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString()); InfoSalesDetails.Rate = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceRate"].Value.ToString()); InfoSalesDetails.UnitId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString()); InfoSalesDetails.UnitConversionId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value.ToString()); InfoSalesDetails.Discount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value.ToString()); if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { InfoSalesDetails.TaxId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceTaxName"].Value.ToString()); InfoSalesDetails.TaxAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceTaxAmount"].Value.ToString()); } else { InfoSalesDetails.TaxId = 0; InfoSalesDetails.TaxAmount = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString() != string.Empty) { InfoSalesDetails.BatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString()); } else { InfoSalesDetails.BatchId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString() != string.Empty) { InfoSalesDetails.GodownId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()); } else { InfoSalesDetails.GodownId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString() != string.Empty) { InfoSalesDetails.RackId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString()); } else { InfoSalesDetails.RackId = 0; } InfoSalesDetails.GrossAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceGrossValue"].Value.ToString()); InfoSalesDetails.NetAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceNetAmount"].Value.ToString()); InfoSalesDetails.Amount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceAmount"].Value.ToString()); BllSalesInvoice.SalesDetailsAdd(InfoSalesDetails); } } } } else { InfoSalesDetails.SalesMasterId = decSalesInvoiceIdToEdit; InfoSalesDetails.SalesDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value); InfoSalesDetails.SlNo = Convert.ToInt32(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSlno"].Value.ToString()); InfoSalesDetails.ProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()); InfoSalesDetails.Qty = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString()); InfoSalesDetails.UnitId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString()); InfoSalesDetails.UnitConversionId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value.ToString()); InfoSalesDetails.Rate = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceRate"].Value.ToString()); InfoSalesDetails.Discount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value.ToString()); if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { InfoSalesDetails.TaxId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceTaxName"].Value.ToString()); InfoSalesDetails.TaxAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceTaxAmount"].Value.ToString()); } else { InfoSalesDetails.TaxId = 0; InfoSalesDetails.TaxAmount = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString() != string.Empty) { InfoSalesDetails.BatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString()); } else { InfoSalesDetails.BatchId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString() != string.Empty) { InfoSalesDetails.GodownId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()); RackComboFill(InfoSalesDetails.GodownId, inI, dgvSalesInvoice.Columns["dgvcmbSalesInvoiceRack"].Index); } else { InfoSalesDetails.GodownId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString() != string.Empty) { InfoSalesDetails.RackId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString()); } else { InfoSalesDetails.RackId = 0; } InfoSalesDetails.GrossAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceGrossValue"].Value.ToString()); InfoSalesDetails.NetAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceNetAmount"].Value.ToString()); InfoSalesDetails.Amount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceAmount"].Value.ToString()); InfoSalesDetails.ExtraDate = DateTime.Now; InfoSalesDetails.Extra1 = string.Empty; InfoSalesDetails.Extra2 = string.Empty; if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSISalesOrderDetailsId"].Value != null) { InfoSalesDetails.OrderDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSISalesOrderDetailsId"].Value.ToString()); } else { InfoSalesDetails.OrderDetailsId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value != null) { InfoSalesDetails.DeliveryNoteDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString()); } else { InfoSalesDetails.DeliveryNoteDetailsId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value != null) { InfoSalesDetails.QuotationDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value.ToString()); } else { InfoSalesDetails.QuotationDetailsId = 0; } BllSalesInvoice.SalesDetailsEdit(InfoSalesDetails); } infoStockPosting.Date = Convert.ToDateTime(txtDate.Text.Trim().ToString()); infoStockPosting.ProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()); infoStockPosting.BatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString()); infoStockPosting.UnitId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString()); if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString() != string.Empty) { infoStockPosting.GodownId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()); } else { infoStockPosting.GodownId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString() != string.Empty) { infoStockPosting.RackId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString()); } else { infoStockPosting.RackId = 0; } if (Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value) == 0) { decimal decResult =BllStockPosting.StockPostingDeleteForSalesInvoiceAgainstDeliveryNote(0, "NA", strVoucherNo, DecSalesInvoiceVoucherTypeId); } else { decimal decResult = BllStockPosting.StockPostingDeleteForSalesInvoiceAgainstDeliveryNote(DecSalesInvoiceVoucherTypeId, strVoucherNo, strVoucherNoTostockPost, decVouchertypeIdTostockPost); } infoStockPosting.Rate = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceRate"].Value.ToString()); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.ExtraDate = DateTime.Now; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value != null) { if (Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString()) != 0) { infoStockPosting.InwardQty = InfoSalesDetails.Qty / bllUnitConvertion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId); infoStockPosting.OutwardQty = 0; infoStockPosting.VoucherNo = strVoucherNoTostockPost; infoStockPosting.AgainstVoucherNo = strVoucherNo; infoStockPosting.InvoiceNo = strInvoiceNoTostockPost; infoStockPosting.AgainstInvoiceNo = strAgainstInvoiceN0; infoStockPosting.VoucherTypeId = decVouchertypeIdTostockPost; infoStockPosting.AgainstVoucherTypeId = DecSalesInvoiceVoucherTypeId; BllStockPosting.StockPostingAdd(infoStockPosting); } } infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = InfoSalesDetails.Qty / bllUnitConvertion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId); infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoStockPosting.InvoiceNo = strAgainstInvoiceN0; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstVoucherTypeId = 0; BllStockPosting.StockPostingAdd(infoStockPosting); } int inAddRowCount = dgvSalesInvoiceLedger.RowCount; infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId; if (isAutomatic) { infoAdditionalCost.VoucherNo = strVoucherNo; } else { infoAdditionalCost.VoucherNo = txtInvoiceNo.Text; } infoAdditionalCost.ExtraDate = DateTime.Now; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; for (int inIAdc = 0; inIAdc < inAddRowCount; inIAdc++) { if (dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvCmbAdditionalCostledgerName"].Value != null && dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString() != string.Empty) { if (dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvtxtAdditionalCoastledgerAmount"].Value != null && dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString() != string.Empty) { infoAdditionalCost.LedgerId = Convert.ToInt32(dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString()); if (cmbDrorCr.SelectedItem.ToString() != "Dr") { infoAdditionalCost.Debit = 0; infoAdditionalCost.Credit = Convert.ToDecimal(dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); } else { infoAdditionalCost.Debit = Convert.ToDecimal(dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); infoAdditionalCost.Credit = 0; } if (dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvtxtAdditionalCostId"].Value != null && dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvtxtAdditionalCostId"].Value.ToString() != string.Empty) { bllAditionalCost.AdditionalCostEditByVoucherTypeIdAndVoucherNo(infoAdditionalCost); } else { bllAditionalCost.AdditionalCostAdd(infoAdditionalCost); } } } } if (cmbDrorCr.SelectedItem.ToString() != "Dr") // here we are debit the cash or bank { decimal decCAshOrPartyId = 0; decCAshOrPartyId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); decimal decTotalAddAmount = Convert.ToDecimal(lblLedgerTotalAmount.Text.Trim().ToString()); infoAdditionalCost.Debit = decTotalAddAmount; infoAdditionalCost.Credit = 0; infoAdditionalCost.LedgerId = decCAshOrPartyId; infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.ExtraDate = DateTime.Now; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; bllAditionalCost.AdditionalCostEditByVoucherTypeIdAndVoucherNo(infoAdditionalCost); } else { decimal decCAshOrBankId = 0; // here we are credit the cash or bank decCAshOrBankId = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString()); decimal decTotalAddAmount = Convert.ToDecimal(lblLedgerTotalAmount.Text.Trim().ToString()); infoAdditionalCost.Debit = 0; infoAdditionalCost.Credit = decTotalAddAmount; infoAdditionalCost.LedgerId = decCAshOrBankId; infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.ExtraDate = DateTime.Now; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; bllAditionalCost.AdditionalCostEditByVoucherTypeIdAndVoucherNo(infoAdditionalCost); } removeSalesInvoiceAdditionalDetails(); if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { int inTaxRowCount = dgvSalesInvoiceTax.RowCount; infoSalesBillTax.SalesMasterId = decSalesInvoiceIdToEdit; infoSalesBillTax.ExtraDate = DateTime.Now; infoSalesBillTax.Extra1 = string.Empty; infoSalesBillTax.Extra2 = string.Empty; for (int inTax = 0; inTax < inTaxRowCount; inTax++) { if (dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxId"].Value != null && dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxId"].Value.ToString() != string.Empty) { if (dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxAmount"].Value != null && dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxAmount"].Value.ToString() != string.Empty) { decimal decAmount = Convert.ToDecimal(dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxAmount"].Value); if (decAmount > 0) { infoSalesBillTax.TaxId = Convert.ToInt32(dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxId"].Value.ToString()); infoSalesBillTax.TaxAmount = Convert.ToDecimal(dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxAmount"].Value.ToString()); BllSalesInvoice.SalesBillTaxEditBySalesMasterIdAndTaxId(infoSalesBillTax); } } } } } if (BllSalesInvoice.SalesInvoiceInvoicePartyCheckEnableBillByBillOrNot(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()))) { infoPartyBalance.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoPartyBalance.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoPartyBalance.VoucherNo = strVoucherNo; infoPartyBalance.InvoiceNo = txtInvoiceNo.Text.Trim(); infoPartyBalance.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "0"; infoPartyBalance.AgainstInvoiceNo = "0"; infoPartyBalance.ReferenceType = "New"; infoPartyBalance.Debit = Convert.ToDecimal(txtGrandTotal.Text.Trim().ToString()); decimal decBalAmount = BllSalesInvoice.SalesInvoiceReciptVoucherDetailsAgainstSI(DecSalesInvoiceVoucherTypeId, strVoucherNo); decimal decCurrentAmount = Convert.ToDecimal(txtGrandTotal.Text.ToString()); if (decCurrentAmount < decBalAmount) { MessageBox.Show("Amount should be greater than " + decBalAmount, "Open_Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvSalesInvoice.Focus(); } else { infoPartyBalance.Credit = 0; infoPartyBalance.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.ToString()); infoPartyBalance.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue); infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.ExtraDate = DateTime.Now; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; BllPartyBalance.PartyBalanceEditByVoucherNoVoucherTypeIdAndReferenceType(infoPartyBalance); } } } catch (Exception ex) { MessageBox.Show("SI: 81" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Party balance save function /// </summary> public void partyBalanceAdd() { PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); try { infoPartyBalance.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoPartyBalance.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoPartyBalance.VoucherNo = strVoucherNo; infoPartyBalance.InvoiceNo = txtInvoiceNo.Text.Trim(); infoPartyBalance.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "0"; infoPartyBalance.AgainstInvoiceNo = "0"; infoPartyBalance.ReferenceType = "New"; infoPartyBalance.Debit = Convert.ToDecimal(txtGrandTotal.Text.Trim().ToString()); infoPartyBalance.Credit = 0; infoPartyBalance.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.ToString()); infoPartyBalance.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.ExtraDate = DateTime.Now; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; BllPartyBalance.PartyBalanceAdd(infoPartyBalance); } catch (Exception ex) { MessageBox.Show("SI: 72" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Ledger posting edit function /// </summary> public void ledgerPostingEdit() { LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); decimal decRate = 0; decimal decimalGrantTotal = 0; decimal decTotalAmount = 0; try { decimalGrantTotal = Convert.ToDecimal(txtGrandTotal.Text.Trim()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decimalGrantTotal = decimalGrantTotal * decRate; infoLedgerPosting.Debit = decimalGrantTotal; infoLedgerPosting.Credit = 0; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); decTotalAmount = TotalNetAmountForLedgerPosting(); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decTotalAmount = decTotalAmount * decRate; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decTotalAmount; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString()); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); decimal decBillDis = 0; decBillDis = Convert.ToDecimal(txtBillDiscount.Text.Trim().ToString()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decBillDis = decBillDis * decRate; if (decBillDis > 0) { infoLedgerPosting.Debit = decBillDis; infoLedgerPosting.Credit = 0; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = 8; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); } if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { foreach (DataGridViewRow dgvrow in dgvSalesInvoiceTax.Rows) { if (dgvrow.Cells["dgvtxtTtaxId"].Value != null && dgvrow.Cells["dgvtxtTtaxId"].Value.ToString() != string.Empty) { decimal decTaxAmount = 0; decTaxAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtTtaxAmount"].Value.ToString()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decTaxAmount = decTaxAmount * decRate; if (decTaxAmount > 0) { infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decTaxAmount; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvtxtTaxLedgerId"].Value.ToString()); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); } } } } if (cmbDrorCr.SelectedItem.ToString() != "Cr") { foreach (DataGridViewRow dgvrow in dgvSalesInvoiceLedger.Rows) { if (dgvrow.Cells["dgvCmbAdditionalCostledgerName"].Value != null && dgvrow.Cells["dgvCmbAdditionalCostledgerName"].Value.ToString() != string.Empty) { decimal decAmount = 0; decAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decAmount = decAmount * decRate; if (decAmount > 0) { infoLedgerPosting.Debit = decAmount; infoLedgerPosting.Credit = 0; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvCmbAdditionalCostledgerName"].Value.ToString()); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); } } } if (cmbCashOrbank.Visible) { decimal decBankOrCashId = 0; decimal decAmountForCr = 0; decBankOrCashId = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString()); decAmountForCr = Convert.ToDecimal(lblLedgerTotalAmount.Text.ToString()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decAmountForCr = decAmountForCr * decRate; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decAmountForCr; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = decBankOrCashId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = "AddCash"; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } else { decimal decBankOrCashId = 0; decimal decAmountForCr = 0; decBankOrCashId = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString()); decAmountForCr = Convert.ToDecimal(lblLedgerTotalAmount.Text.ToString()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decAmountForCr = decAmountForCr * decRate; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decAmountForCr; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = decBankOrCashId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = "AddCash"; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); } } else { string strVno = string.Empty; strVno = infoLedgerPosting.VoucherNo; BllLedgerPosting.LedgerPostingDeleteByVoucherTypeIdAndLedgerIdAndVoucherNoAndExtra(DecSalesInvoiceVoucherTypeId, decBankOrCashIdForEdit, strVno, "AddCash"); foreach (DataGridViewRow dgvrow in dgvSalesInvoiceLedger.Rows) { if (dgvrow.Cells["dgvCmbAdditionalCostledgerName"].Value != null && dgvrow.Cells["dgvCmbAdditionalCostledgerName"].Value.ToString() != string.Empty) { decimal decAmount = 0; decAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); decRate = BllExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); decAmount = decAmount * decRate; if (decAmount > 0) { infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decAmount; infoLedgerPosting.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoLedgerPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoLedgerPosting.VoucherNo = strVoucherNo; infoLedgerPosting.InvoiceNo = txtInvoiceNo.Text.Trim(); infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvCmbAdditionalCostledgerName"].Value.ToString()); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; BllLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); } } } } } catch (Exception ex) { MessageBox.Show("SI: 82" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Edit Function /// </summary> public void EditFunction() { try { removeSalesInvoiceDetails(); SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); InfoSalesMaster = BllSalesInvoice.SalesMasterView(decSalesInvoiceIdToEdit); if (InfoSalesMaster.DeliveryNoteMasterId != 0) { DeliveryNoteMasterInfo infoDeliveryNote = new DeliveryNoteMasterInfo(); infoDeliveryNote = new DeliveryNoteBll().DeliveryNoteMasterView(InfoSalesMaster.DeliveryNoteMasterId); new StockPostingBll().StockPostingDeleteForSalesInvoiceAgainstDeliveryNote (InfoSalesMaster.VoucherTypeId, InfoSalesMaster.VoucherNo, infoDeliveryNote.VoucherNo, infoDeliveryNote.VoucherTypeId); } new StockPostingBll().StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType (0, "NA", InfoSalesMaster.VoucherNo, InfoSalesMaster.VoucherTypeId); InfoSalesMaster.SalesMasterId = decSalesInvoiceIdToEdit; InfoSalesMaster.AdditionalCost = Convert.ToDecimal(lblLedgerTotalAmount.Text); InfoSalesMaster.BillDiscount = Convert.ToDecimal(txtBillDiscount.Text.Trim()); InfoSalesMaster.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.Trim().ToString()); InfoSalesMaster.CustomerName = txtCustomer.Text.Trim(); InfoSalesMaster.Date = Convert.ToDateTime(txtDate.Text.ToString()); InfoSalesMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); InfoSalesMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); InfoSalesMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoSalesMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text.Trim()); InfoSalesMaster.InvoiceNo = txtInvoiceNo.Text.Trim(); InfoSalesMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); InfoSalesMaster.VoucherTypeId = DecSalesInvoiceVoucherTypeId; InfoSalesMaster.VoucherNo = strVoucherNo; if (isAutomatic) { InfoSalesMaster.SuffixPrefixId = decSalseInvoiceSuffixPrefixId; } else { InfoSalesMaster.SuffixPrefixId = 0; } if (cmbSalesMode.Text == "Against SalesOrder") { InfoSalesMaster.OrderMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()); } else { InfoSalesMaster.OrderMasterId = 0; } if (cmbSalesMode.Text == "Against Delivery Note") { InfoSalesMaster.DeliveryNoteMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()); } else { InfoSalesMaster.DeliveryNoteMasterId = 0; } if (cmbSalesMode.Text == "Against Quotation") { InfoSalesMaster.QuotationMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()); } else { InfoSalesMaster.QuotationMasterId = 0; } InfoSalesMaster.Narration = txtNarration.Text.Trim(); InfoSalesMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); InfoSalesMaster.SalesAccount = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString()); InfoSalesMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text.Trim()); if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { InfoSalesMaster.TaxAmount = Convert.ToDecimal(lblTaxTotalAmount.Text.Trim()); } else { InfoSalesMaster.TaxAmount = 0; } InfoSalesMaster.UserId = PublicVariables._decCurrentUserId; InfoSalesMaster.LrNo = txtVehicleNo.Text; InfoSalesMaster.TransportationCompany = txtTransportCompany.Text.Trim(); InfoSalesMaster.POS = false; InfoSalesMaster.CounterId = 0; InfoSalesMaster.ExtraDate = DateTime.Now; InfoSalesMaster.Extra1 = string.Empty; InfoSalesMaster.Extra2 = string.Empty; BllSalesInvoice.SalesMasterEdit(InfoSalesMaster); removeSalesInvoiceDetails(); SalesInvoiceDetailsEditFill(); if (cmbCashOrParty.Enabled) { LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); BllLedgerPosting.LedgerPostDelete(strVoucherNo, DecSalesInvoiceVoucherTypeId); ledgerPostingAdd(); } else { ledgerPostingEdit(); } Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { SettingsBll BllSettings = new SettingsBll(); if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesInvoiceIdToEdit); } else { Print(decSalesInvoiceIdToEdit); } } this.Close(); } catch (Exception ex) { MessageBox.Show("SI: 78" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Call Corresponding Voucher to View details for updation in edit mode /// </summary> public void GotoSalesInvoice() { try { //SalesMasterSP SpMaster = new SalesMasterSP(); SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll(); SalesMasterInfo InfoMaster = new SalesMasterInfo(); InfoMaster = BllSalesInvoice.SalesMasterView(Convert.ToDecimal(dgvVoucherSearch.CurrentRow.Cells["Id"].Value.ToString())); if (InfoMaster.POS == true) { frmPOS objfrm = new frmPOS(); objfrm.WindowState = FormWindowState.Normal; objfrm.MdiParent = formMDI.MDIObj; objfrm.Show(); objfrm.CallFromVoucherSearch(this, Convert.ToDecimal(dgvVoucherSearch.CurrentRow.Cells["Id"].Value.ToString())); } else { frmSalesInvoice objfrmSalesInvoice = new frmSalesInvoice(); frmSalesInvoice open = Application.OpenForms["frmSalesInvoice"] as frmSalesInvoice; if (open == null) { objfrmSalesInvoice.WindowState = FormWindowState.Normal; objfrmSalesInvoice.MdiParent = formMDI.MDIObj; objfrmSalesInvoice.Show(); objfrmSalesInvoice.CallFromVoucherSearch(this, Convert.ToDecimal(dgvVoucherSearch.CurrentRow.Cells["Id"].Value.ToString())); } else { open.MdiParent = formMDI.MDIObj; if (open.WindowState == FormWindowState.Minimized) { open.WindowState = FormWindowState.Normal; } else { open.Activate(); } open.CallFromVoucherSearch(this, Convert.ToDecimal(dgvVoucherSearch.CurrentRow.Cells["Id"].Value.ToString())); open.BringToFront(); } } } catch (Exception ex) { MessageBox.Show("VS24:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// FunctionToreturn fromregisterclick /// </summary> public void FillRegisterOrReport() { SalesReturnBll bllSalesReturn = new SalesReturnBll(); try { isFromOther = true; btnSave.Text = "Update"; btnDelete.Enabled = true; CashOrPartyUnderSundryDebitorComboFill(cmbCashOrParty); DataTable dtblSalesMaster = new DataTable(); List<DataTable> ListObjMaster = new List<DataTable>(); ListObjMaster = bllSalesReturn.SalesReturnMasterViewBySalesReturnMasterId(salesReturnMasterId); decSalesReturnMasterId = salesReturnMasterId; DecSalesReturnVoucherTypeId = Convert.ToDecimal(ListObjMaster[0].Rows[0]["voucherTypeId"].ToString()); VoucherTypeInfo infoVoucherType = new VoucherTypeInfo(); infoVoucherType = BllVoucherType.VoucherTypeView(DecSalesReturnVoucherTypeId); this.Text = infoVoucherType.VoucherTypeName; if (infoVoucherType.MethodOfVoucherNumbering == "Manual") { txtReturnNo.Text = ListObjMaster[0].Rows[0]["invoiceNo"].ToString(); ManualReturnNo = ListObjMaster[0].Rows[0]["invoiceNo"].ToString(); txtReturnNo.Enabled = true; } else { txtReturnNo.Text = ListObjMaster[0].Rows[0]["invoiceNo"].ToString(); txtReturnNo.Enabled = false; } if (ListObjMaster[0].Rows.Count > 0) { txtDate.Text = ListObjMaster[0].Rows[0]["date"].ToString(); dtpDate.Value = Convert.ToDateTime(txtDate.Text); if (ListObjMaster[0].Rows[0]["grandTotal"].ToString() != string.Empty) { txtGrandTotal.Text = ListObjMaster[0].Rows[0]["grandTotal"].ToString(); } strVoucherNo = ListObjMaster[0].Rows[0]["voucherNo"].ToString(); if (ListObjMaster[0].Rows[0]["ledgerId"].ToString() != string.Empty) { cmbCashOrParty.SelectedValue = ListObjMaster[0].Rows[0]["ledgerId"].ToString(); } cmbVoucherTypeComboFill(); if (ListObjMaster[0].Rows[0]["SMVoucherTypeId"].ToString() != string.Empty) { cmbVoucherType.SelectedValue = ListObjMaster[0].Rows[0]["SMVoucherTypeId"].ToString(); } else { cmbVoucherType.SelectedValue = 0; } cmbInvoiceComboFill(); if (ListObjMaster[0].Rows[0]["pricingLevelId"].ToString() != string.Empty) { cmbPricingLevel.SelectedValue = ListObjMaster[0].Rows[0]["pricingLevelId"].ToString(); } if (ListObjMaster[0].Rows[0]["salesAccount"].ToString() != string.Empty) { cmbSalesAccount.SelectedValue = ListObjMaster[0].Rows[0]["salesAccount"].ToString(); } if (ListObjMaster[0].Rows[0]["employeeId"].ToString() != string.Empty) { cmbSalesMan.SelectedValue = ListObjMaster[0].Rows[0]["employeeId"].ToString(); } if (ListObjMaster[0].Rows[0]["exchangeRateId"].ToString() != string.Empty) { cmbCurrency.SelectedValue = ListObjMaster[0].Rows[0]["exchangeRateId"].ToString(); } txtNarration.Text = ListObjMaster[0].Rows[0]["narration"].ToString(); txtLRNo.Text = ListObjMaster[0].Rows[0]["lrNo"].ToString(); txtTransportationComp.Text = ListObjMaster[0].Rows[0]["transportationCompany"].ToString(); if (ListObjMaster[0].Rows[0]["salesMasterId"].ToString() != string.Empty && Convert.ToDecimal(ListObjMaster[0].Rows[0]["salesMasterId"].ToString()) != 0) { cmbInvoiceNo.SelectedValue = ListObjMaster[0].Rows[0]["salesMasterId"].ToString(); decinvoiceno = Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()); dtblSalesReturnMasterViewBySMID = bllSalesReturn.SalesReturnMasterViewBySalesMasterId(Convert.ToDecimal(ListObjMaster[0].Rows[0]["salesMasterId"].ToString())); } isInvoiceFill = false; if (ListObjMaster[0].Rows[0]["voucherTypeId"].ToString() != string.Empty) { decSalesReturnVoucherTypeId = Convert.ToDecimal(ListObjMaster[0].Rows[0]["voucherTypeId"].ToString()); } TaxGridFill(); if (cmbInvoiceNo.SelectedValue != null) { infoSalesMaster = BllSalesInvoice.SalesMasterViewBySalesMasterId(Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString())); } List<DataTable> ListObj1 = new List<DataTable>(); ListObj1 = bllSalesReturn.SalesReturnDetailsViewBySalesReturnMasterId(salesReturnMasterId); dtblSalesInvoice = ListObj1[0]; foreach (DataRow drowDetails in ListObj1[0].Rows) { dgvSalesReturn.Rows.Add(); if (drowDetails["salesReturnDetailsId"].ToString() != string.Empty) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["salesReturnDetailsId"].Value = Convert.ToDecimal(drowDetails["salesReturnDetailsId"].ToString()); } if (drowDetails["salesDetailsId"].ToString() != string.Empty) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["salesDetailsId"].Value = drowDetails["salesDetailsId"].ToString(); } else { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["salesDetailsId"].Value = 0; } if (drowDetails["productId"].ToString() != string.Empty) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["productId"].Value = drowDetails["productId"].ToString(); List<DataTable> listObj = BllSalesInvoice.SalesReturnGrideFillNewByProductId(Convert.ToDecimal(drowDetails["productId"].ToString())); foreach (DataRow drowDetails1 in listObj[0].Rows) { if (drowDetails1["barcode"].ToString() != string.Empty) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextBarcode"].Value = drowDetails1["barcode"].ToString(); } if (drowDetails1["productCode"].ToString() != string.Empty) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextProductCode"].Value = drowDetails1["productCode"].ToString(); } if (drowDetails1["productName"].ToString() != string.Empty) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextProductName"].Value = drowDetails1["productName"].ToString(); } if (cmbInvoiceNo.Visible == true) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbUnit"].ReadOnly = true; } if (drowDetails["unitId"].ToString() != string.Empty) { decProductId = decimal.Parse(dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["productId"].Value.ToString()); UnitComboFill(decProductId, dgvSalesReturn.Rows.Count - 2, dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbUnit"].ColumnIndex); dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbUnit"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString()); } else { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbUnit"].Value = 1; } if (drowDetails["goDownId"].ToString() != string.Empty) { DGVGodownComboFill(); dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbGodown"].Value = Convert.ToDecimal(drowDetails["goDownId"].ToString()); } else { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbGodown"].Value = 1; } if (drowDetails["rackId"].ToString() != string.Empty) { RackComboFill(Convert.ToDecimal(dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbGodown"].Value.ToString()), dgvSalesReturn.Rows.Count - 2, dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbRack"].ColumnIndex); dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbRack"].Value = Convert.ToDecimal(drowDetails["rackId"].ToString()); } else { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbRack"].Value = 1; } if (drowDetails["batchId"].ToString() != string.Empty) { BatchComboFill(decProductId, dgvSalesReturn.Rows.Count - 2, dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbBatch"].ColumnIndex); dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString()); } if (drowDetails["unitConversionId"].ToString() != string.Empty) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["unitConversionId"].Value = drowDetails["unitConversionId"].ToString(); } else { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["unitConversionId"].Value = 0; } if (ListObjMaster[0].Rows[0]["SMVoucherTypeId"].ToString() != string.Empty) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbBatch"].ReadOnly = true; } if (drowDetails["taxId"].ToString() != string.Empty) { if (Convert.ToDecimal(drowDetails["taxId"].ToString()) != 0) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTaxId"].Value = Convert.ToDecimal(drowDetails["taxId"].ToString()); dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbTax"].Value = Convert.ToDecimal(drowDetails["taxId"].ToString()); strTaxRate = bllSalesReturn.TaxRateFindForTaxAmmountCalByTaxId(Convert.ToDecimal(drowDetails["taxId"].ToString())); } } else { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbTax"].Value = 1; } if (drowDetails["qty"].ToString() != string.Empty) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextQty"].Value = Math.Round(Convert.ToDecimal(drowDetails["qty"].ToString()), PublicVariables._inNoOfDecimalPlaces); decQty = Math.Round(Convert.ToDecimal(drowDetails["qty"].ToString()), PublicVariables._inNoOfDecimalPlaces); } else { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextQty"].Value = 0.00; decQty = 0; } if (drowDetails["rate"].ToString() != string.Empty) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextRate"].Value = Math.Round(Convert.ToDecimal(drowDetails["rate"].ToString()), PublicVariables._inNoOfDecimalPlaces); decRate = Convert.ToDecimal(drowDetails["rate"].ToString()); } else { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextRate"].Value = 0.00; decRate = 0; } if (drowDetails["grossAmount"].ToString() != string.Empty) { //dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].ReadOnly = false; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].Value = Math.Round(Convert.ToDecimal(drowDetails["grossAmount"].ToString()), PublicVariables._inNoOfDecimalPlaces); // dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].ReadOnly = true; } else { //dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].ReadOnly = false; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].Value = 0.00; //dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextGrossValue"].ReadOnly = true; } if (drowDetails["discount"].ToString() != string.Empty) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextDiscountPercentage"].Value = 0.00; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextDiscountAmount"].Value = Math.Round(Convert.ToDecimal(drowDetails["discount"].ToString()), PublicVariables._inNoOfDecimalPlaces); } else { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextDiscountAmount"].Value = 0.00; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextDiscountPercentage"].Value = 0.00; } if (drowDetails["netAmount"].ToString() != string.Empty) { // dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].ReadOnly = false; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].Value = Math.Round(Convert.ToDecimal(drowDetails["netAmount"].ToString()), PublicVariables._inNoOfDecimalPlaces); // dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].ReadOnly = true; } else { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].ReadOnly = false; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].Value = 0.00; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextNetValue"].ReadOnly = true; } if (drowDetails["taxAmount"].ToString() != string.Empty) { //dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].ReadOnly = false; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].Value = Math.Round(Convert.ToDecimal(drowDetails["taxAmount"].ToString()), PublicVariables._inNoOfDecimalPlaces); //dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].ReadOnly = true; } else { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].Value = 0.00; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].ReadOnly = true; } if (drowDetails["amount"].ToString() != string.Empty) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextAmount1"].Value = Math.Round(Convert.ToDecimal(drowDetails["amount"].ToString()), PublicVariables._inNoOfDecimalPlaces); dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextAmount1"].ReadOnly = true; } else { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextAmount1"].Value = 0.00; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextAmount1"].ReadOnly = true; } if (cmbInvoiceNo.Visible == true) { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextBarcode"].ReadOnly = true; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextProductCode"].ReadOnly = true; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextProductName"].ReadOnly = true; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextQty"].ReadOnly = true; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbUnit"].ReadOnly = true; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbGodown"].ReadOnly = true; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbRack"].ReadOnly = true; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbBatch"].ReadOnly = true; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextRate"].ReadOnly = true; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvTextDiscountPercentage"].ReadOnly = true; dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 1].Cells["dgvCmbTax"].ReadOnly = true; } dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["conversionRate"].Value = drowDetails["conversionRate"].ToString(); foreach (DataGridViewRow item1 in dgvSalesReturn2.Rows) { if (item1.Cells["dgvTextTaxId"].Value != null) { if (dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvCmbTax"].Value.ToString() == item1.Cells["dgvTextTaxId"].Value.ToString()) { item1.Cells["dgvTextAmount"].Value = dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["dgvTextTaxAmount"].Value; } } } } } else { dgvSalesReturn.Rows[dgvSalesReturn.Rows.Count - 2].Cells["productId"].Value = 0; } TotalAmountCalculation(); } if (!isSalesReturnFormActive) { ListObj = bllSalesReturnBill.TaxDetailsViewBySalesReturnMasterId(salesReturnMasterId); foreach (DataRow item1 in ListObj[0].Rows) { dgvSalesReturn2.Rows.Add(); dgvSalesReturn2.Rows[dgvSalesReturn2.Rows.Count - 2].Cells["dgvTextTaxName"].Value = item1["taxName"].ToString(); dgvSalesReturn2.Rows[dgvSalesReturn2.Rows.Count - 2].Cells["dgvTextAmount"].Value = Math.Round(Convert.ToDecimal(item1["taxAmount"].ToString()), PublicVariables._inNoOfDecimalPlaces); dgvSalesReturn2.Rows[dgvSalesReturn2.Rows.Count - 2].Cells["dgvRate"].Value = item1["rate"].ToString(); dgvSalesReturn2.Rows[dgvSalesReturn2.Rows.Count - 2].Cells["dgvTextTaxId"].Value = item1["taxId"].ToString(); } } txtBillDiscount.Text = Convert.ToString(Math.Round(Convert.ToDecimal(ListObjMaster[0].Rows[0]["discount"].ToString()), PublicVariables._inNoOfDecimalPlaces)); SerialNo2(); TotalBillTaxCalculation(); CessTaxamountCalculation(); TotalTaxAmtCalculation(); if (txtBillDiscount.Text != string.Empty) { decimal decDiscount = Convert.ToDecimal(txtBillDiscount.Text); decimal decTotalAmt = Convert.ToDecimal(txtTotalAmount.Text); if (decTotalAmt > decDiscount) { decimal decGrandTotal = decTotalAmt + decTotalBillTaxAmount + decTotalCessTaxamount - decDiscount; decGrandTotal = Math.Round(decGrandTotal, PublicVariables._inNoOfDecimalPlaces); txtGrandTotal.Text = decGrandTotal.ToString(); } } // SerialNo(); } else { MessageBox.Show("No record exists", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("SR28:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }