/// <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(); StockPostingSP spStockPosting = new StockPostingSP(); PartyBalanceSP spPartyBalance = new PartyBalanceSP(); AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo(); AdditionalCostSP spAdditionalCost = new AdditionalCostSP(); SalesBillTaxSP spSalesBillTax = new SalesBillTaxSP(); SalesBillTaxInfo infoSalesBillTax = new SalesBillTaxInfo(); UnitConvertionSP SPUnitConversion = new UnitConvertionSP(); try { string strAgainstInvoiceN0 = txtInvoiceNo.Text.Trim(); for (int inI = 0; inI < dgvSalesInvoice.Rows.Count - 1; inI++) { decimal decRefStatus = spSalesMaster.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 = spSalesMaster.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()); spSalesDetails.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; } spSalesDetails.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 = spStockPosting.StockPostingDeleteForSalesInvoiceAgainstDeliveryNote(0, "NA", strVoucherNo, DecSalesInvoiceVoucherTypeId); } else { decimal decResult = spStockPosting.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 / SPUnitConversion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId); infoStockPosting.OutwardQty = 0; infoStockPosting.VoucherNo = strVoucherNoTostockPost; infoStockPosting.AgainstVoucherNo = strVoucherNo; infoStockPosting.InvoiceNo = strInvoiceNoTostockPost; infoStockPosting.AgainstInvoiceNo = strAgainstInvoiceN0; infoStockPosting.VoucherTypeId = decVouchertypeIdTostockPost; infoStockPosting.AgainstVoucherTypeId = DecSalesInvoiceVoucherTypeId; spStockPosting.StockPostingAdd(infoStockPosting); } } infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = InfoSalesDetails.Qty / SPUnitConversion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId); infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoStockPosting.InvoiceNo = strAgainstInvoiceN0; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstVoucherTypeId = 0; spStockPosting.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) { spAdditionalCost.AdditionalCostEditByVoucherTypeIdAndVoucherNo(infoAdditionalCost); } else { spAdditionalCost.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; spAdditionalCost.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; spAdditionalCost.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()); spSalesBillTax.SalesBillTaxEditBySalesMasterIdAndTaxId(infoSalesBillTax); } } } } } if (spSalesMaster.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 = spSalesDetails.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; spPartyBalance.PartyBalanceEditByVoucherNoVoucherTypeIdAndReferenceType(infoPartyBalance); } } } catch (Exception ex) { MessageBox.Show("SI: 81" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Ledger posting edit function /// </summary> public void ledgerPostingEdit() { LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); ExchangeRateSP spExchangeRate = new ExchangeRateSP(); decimal decRate = 0; decimal decimalGrantTotal = 0; decimal decTotalAmount = 0; try { decimalGrantTotal = Convert.ToDecimal(txtGrandTotal.Text.Trim()); decRate = spExchangeRate.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; spLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); decTotalAmount = TotalNetAmountForLedgerPosting(); decRate = spExchangeRate.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; spLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); decimal decBillDis = 0; decBillDis = Convert.ToDecimal(txtBillDiscount.Text.Trim().ToString()); decRate = spExchangeRate.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; spLedgerPosting.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 = spExchangeRate.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; spLedgerPosting.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 = spExchangeRate.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; spLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); } } } if (cmbCashOrbank.Visible) { decimal decBankOrCashId = 0; decimal decAmountForCr = 0; decBankOrCashId = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString()); decAmountForCr = Convert.ToDecimal(lblLedgerTotalAmount.Text.ToString()); decRate = spExchangeRate.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; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } else { decimal decBankOrCashId = 0; decimal decAmountForCr = 0; decBankOrCashId = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString()); decAmountForCr = Convert.ToDecimal(lblLedgerTotalAmount.Text.ToString()); decRate = spExchangeRate.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; spLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); } } else { string strVno = string.Empty; strVno = infoLedgerPosting.VoucherNo; spLedgerPosting.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 = spExchangeRate.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; spLedgerPosting.LedgerPostingEditByVoucherTypeAndVoucherNoAndLedgerId(infoLedgerPosting); } } } } } catch (Exception ex) { MessageBox.Show("SI: 82" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Print function in crystal report /// </summary> /// <param name="decSalesMasterId"></param> public void Print(decimal decSalesMasterId) { SalesMasterSP spSalesMaster = new SalesMasterSP(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); try { DataSet dsSalesInvoice = spSalesMaster.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> /// Edit Function /// </summary> public void EditFunction() { try { removeSalesInvoiceDetails(); SalesMasterSP spSalesMaster = new SalesMasterSP(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); InfoSalesMaster = spSalesMaster.SalesMasterView(decSalesInvoiceIdToEdit); if (InfoSalesMaster.DeliveryNoteMasterId != 0) { DeliveryNoteMasterInfo infoDeliveryNote = new DeliveryNoteMasterInfo(); infoDeliveryNote = new DeliveryNoteMasterSP().DeliveryNoteMasterView(InfoSalesMaster.DeliveryNoteMasterId); new StockPostingSP().StockPostingDeleteForSalesInvoiceAgainstDeliveryNote (InfoSalesMaster.VoucherTypeId, InfoSalesMaster.VoucherNo, infoDeliveryNote.VoucherNo, infoDeliveryNote.VoucherTypeId); } new StockPostingSP().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; spSalesMaster.SalesMasterEdit(InfoSalesMaster); removeSalesInvoiceDetails(); SalesInvoiceDetailsEditFill(); if (cmbCashOrParty.Enabled) { LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); spLedgerPosting.LedgerPostDelete(strVoucherNo, DecSalesInvoiceVoucherTypeId); ledgerPostingAdd(); } else { ledgerPostingEdit(); } Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { SettingsSP spSettings = new SettingsSP(); if (spSettings.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> /// Save function /// </summary> public void SaveFunction() { SalesMasterSP spSalesMaster = new SalesMasterSP(); SalesDetailsSP spSalesDetails = new SalesDetailsSP(); StockPostingInfo infoStockPosting = new StockPostingInfo(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); SalesDetailsInfo InfoSalesDetails = new SalesDetailsInfo(); StockPostingSP spStockPosting = new StockPostingSP(); AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo(); AdditionalCostSP spAdditionalCost = new AdditionalCostSP(); SalesBillTaxInfo infoSalesBillTax = new SalesBillTaxInfo(); SalesBillTaxSP spSalesBillTax = new SalesBillTaxSP(); UnitConvertionSP SPUnitConversion = new UnitConvertionSP(); 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 = spSalesMaster.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()); spSalesDetails.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 / SPUnitConversion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId); infoStockPosting.OutwardQty = 0; infoStockPosting.VoucherNo = strVoucherNoTostockPost; infoStockPosting.AgainstVoucherNo = strVoucherNo; infoStockPosting.InvoiceNo = strInvoiceNoTostockPost; infoStockPosting.AgainstInvoiceNo = strAgainstInvoiceN0; infoStockPosting.VoucherTypeId = decVouchertypeIdTostockPost; infoStockPosting.AgainstVoucherTypeId = DecSalesInvoiceVoucherTypeId; spStockPosting.StockPostingAdd(infoStockPosting); } } infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = InfoSalesDetails.Qty / SPUnitConversion.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; spStockPosting.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()); spSalesBillTax.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; } spAdditionalCost.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; spAdditionalCost.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; spAdditionalCost.AdditionalCostAdd(infoAdditionalCost); } } } ledgerPostingAdd(); if (spSalesMaster.SalesInvoiceInvoicePartyCheckEnableBillByBillOrNot(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()))) { partyBalanceAdd(); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked == true) { SettingsSP spSettings = new SettingsSP(); if (spSettings.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> /// Party balance save function /// </summary> public void partyBalanceAdd() { PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); PartyBalanceSP spPartyBalance = new PartyBalanceSP(); 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; spPartyBalance.PartyBalanceAdd(infoPartyBalance); } catch (Exception ex) { MessageBox.Show("SI: 72" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for SalesMaster View By SalesMasterId /// </summary> /// <param name="salesMasterId"></param> /// <returns></returns> public SalesMasterInfo SalesMasterViewBySalesMasterId(decimal salesMasterId) { SalesMasterInfo infoSalesMaster = new SalesMasterInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("SalesMasterViewBySalesMasterId", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@salesMasterId", SqlDbType.Decimal); sprmparam.Value = salesMasterId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { infoSalesMaster.InvoiceNo = sdrreader["invoiceNo"].ToString(); infoSalesMaster.VoucherNo = sdrreader["voucherNo"].ToString(); infoSalesMaster.VoucherTypeId = Convert.ToDecimal(sdrreader["voucherTypeId"].ToString()); } } catch (Exception ex) { Messages.ErrorMessage(ex.ToString()); } finally { sqlcon.Close(); } return infoSalesMaster; }
/// <summary> /// Function to get particular values from SalesMaster Table based on the parameter /// </summary> /// <param name="salesMasterId"></param> /// <returns></returns> public SalesMasterInfo SalesMasterView(string salesMasterId) { SalesMasterInfo salesmasterinfo = new SalesMasterInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("SalesMasterView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@salesMasterId", SqlDbType.Decimal); sprmparam.Value = salesMasterId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { salesmasterinfo.SalesMasterId = decimal.Parse(sdrreader[0].ToString()); salesmasterinfo.VoucherNo = sdrreader[1].ToString(); salesmasterinfo.InvoiceNo = sdrreader[2].ToString(); salesmasterinfo.VoucherTypeId = decimal.Parse(sdrreader[3].ToString()); salesmasterinfo.SuffixPrefixId = decimal.Parse(sdrreader[4].ToString()); salesmasterinfo.Date = DateTime.Parse(sdrreader[5].ToString()); salesmasterinfo.CreditPeriod = int.Parse(sdrreader[6].ToString()); salesmasterinfo.LedgerId = decimal.Parse(sdrreader[7].ToString()); salesmasterinfo.PricinglevelId = decimal.Parse(sdrreader[8].ToString()); salesmasterinfo.EmployeeId = decimal.Parse(sdrreader[9].ToString()); salesmasterinfo.SalesAccount = decimal.Parse(sdrreader[10].ToString()); salesmasterinfo.DeliveryNoteMasterId = decimal.Parse(sdrreader[11].ToString()); salesmasterinfo.OrderMasterId = decimal.Parse(sdrreader[12].ToString()); salesmasterinfo.Narration = sdrreader[13].ToString(); salesmasterinfo.CustomerName = sdrreader[14].ToString(); salesmasterinfo.ExchangeRateId = decimal.Parse(sdrreader[15].ToString()); salesmasterinfo.TaxAmount = decimal.Parse(sdrreader[16].ToString()); salesmasterinfo.AdditionalCost = decimal.Parse(sdrreader[17].ToString()); salesmasterinfo.BillDiscount = decimal.Parse(sdrreader[18].ToString()); salesmasterinfo.GrandTotal = decimal.Parse(sdrreader[19].ToString()); salesmasterinfo.TotalAmount = decimal.Parse(sdrreader[20].ToString()); salesmasterinfo.UserId = decimal.Parse(sdrreader[21].ToString()); salesmasterinfo.LrNo = sdrreader[22].ToString(); salesmasterinfo.TransportationCompany = sdrreader[23].ToString(); salesmasterinfo.QuotationMasterId = decimal.Parse(sdrreader[24].ToString()); salesmasterinfo.POS = bool.Parse(sdrreader[25].ToString()); salesmasterinfo.CounterId = decimal.Parse(sdrreader[26].ToString()); salesmasterinfo.FinancialYearId = decimal.Parse(sdrreader[27].ToString()); salesmasterinfo.ExtraDate = DateTime.Parse(sdrreader[28].ToString()); salesmasterinfo.Extra1 = sdrreader[29].ToString(); salesmasterinfo.Extra2 = sdrreader[30].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return salesmasterinfo; }
/// <summary> /// Function to insert values to SalesMaster Table /// </summary> /// <param name="salesmasterinfo"></param> /// <returns></returns> public decimal SalesMasterAdd(SalesMasterInfo salesmasterinfo) { decimal decSalesMasterId = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("SalesMasterAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam.Value = salesmasterinfo.VoucherNo; sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam.Value = salesmasterinfo.InvoiceNo; sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.VoucherTypeId; sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.SuffixPrefixId; sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam.Value = salesmasterinfo.Date; sprmparam = sccmd.Parameters.Add("@creditPeriod", SqlDbType.Int); sprmparam.Value = salesmasterinfo.CreditPeriod; sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.LedgerId; sprmparam = sccmd.Parameters.Add("@pricinglevelId", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.PricinglevelId; sprmparam = sccmd.Parameters.Add("@employeeId", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.EmployeeId; sprmparam = sccmd.Parameters.Add("@salesAccount", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.SalesAccount; sprmparam = sccmd.Parameters.Add("@deliveryNoteMasterId", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.DeliveryNoteMasterId; sprmparam = sccmd.Parameters.Add("@orderMasterId", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.OrderMasterId; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = salesmasterinfo.Narration; sprmparam = sccmd.Parameters.Add("@customerName", SqlDbType.VarChar); sprmparam.Value = salesmasterinfo.CustomerName; sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.ExchangeRateId; sprmparam = sccmd.Parameters.Add("@taxAmount", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.TaxAmount; sprmparam = sccmd.Parameters.Add("@additionalCost", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.AdditionalCost; sprmparam = sccmd.Parameters.Add("@billDiscount", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.BillDiscount; sprmparam = sccmd.Parameters.Add("@grandTotal", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.GrandTotal; sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.TotalAmount; sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.UserId; sprmparam = sccmd.Parameters.Add("@lrNo", SqlDbType.VarChar); sprmparam.Value = salesmasterinfo.LrNo; sprmparam = sccmd.Parameters.Add("@transportationCompany", SqlDbType.VarChar); sprmparam.Value = salesmasterinfo.TransportationCompany; sprmparam = sccmd.Parameters.Add("@quotationMasterId", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.QuotationMasterId; sprmparam = sccmd.Parameters.Add("@POS", SqlDbType.Bit); sprmparam.Value = salesmasterinfo.POS; sprmparam = sccmd.Parameters.Add("@counterId", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.CounterId; sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam.Value = salesmasterinfo.FinancialYearId; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = salesmasterinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = salesmasterinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = salesmasterinfo.Extra2; decSalesMasterId = Convert.ToDecimal(sccmd.ExecuteScalar().ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return decSalesMasterId; }
/// <summary> /// Call Corresponding Voucher to View details for updation in edit mode /// </summary> public void GotoSalesInvoice() { try { SalesMasterSP SpMaster = new SalesMasterSP(); SalesMasterInfo InfoMaster = new SalesMasterInfo(); InfoMaster = SpMaster.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() { SalesReturnMasterSP spSalesReturnMaster = new SalesReturnMasterSP(); SalesReturnDetailsSP spSalesReturnDetails = new SalesReturnDetailsSP(); try { isFromOther = true; btnSave.Text = "Update"; btnDelete.Enabled = true; CashOrPartyUnderSundryDebitorComboFill(cmbCashOrParty); DataTable dtblSalesMaster = new DataTable(); DataTable dtblSalesReturnMaster = new DataTable(); dtblSalesReturnMaster = spSalesReturnMaster.SalesReturnMasterViewBySalesReturnMasterId(salesReturnMasterId); decSalesReturnMasterId = salesReturnMasterId; DecSalesReturnVoucherTypeId = Convert.ToDecimal(dtblSalesReturnMaster.Rows[0]["voucherTypeId"].ToString()); VoucherTypeInfo infoVoucherType = new VoucherTypeInfo(); infoVoucherType = spVoucherType.VoucherTypeView(DecSalesReturnVoucherTypeId); this.Text = infoVoucherType.VoucherTypeName; if (infoVoucherType.MethodOfVoucherNumbering == "Manual") { txtReturnNo.Text = dtblSalesReturnMaster.Rows[0]["invoiceNo"].ToString(); ManualReturnNo = dtblSalesReturnMaster.Rows[0]["invoiceNo"].ToString(); txtReturnNo.Enabled = true; } else { txtReturnNo.Text = dtblSalesReturnMaster.Rows[0]["invoiceNo"].ToString(); txtReturnNo.Enabled = false; } if (dtblSalesReturnMaster.Rows.Count > 0) { txtDate.Text = dtblSalesReturnMaster.Rows[0]["date"].ToString(); dtpDate.Value = Convert.ToDateTime(txtDate.Text); if (dtblSalesReturnMaster.Rows[0]["grandTotal"].ToString() != string.Empty) { txtGrandTotal.Text = dtblSalesReturnMaster.Rows[0]["grandTotal"].ToString(); } strVoucherNo = dtblSalesReturnMaster.Rows[0]["voucherNo"].ToString(); if (dtblSalesReturnMaster.Rows[0]["ledgerId"].ToString() != string.Empty) { cmbCashOrParty.SelectedValue = dtblSalesReturnMaster.Rows[0]["ledgerId"].ToString(); } cmbVoucherTypeComboFill(); if (dtblSalesReturnMaster.Rows[0]["SMVoucherTypeId"].ToString() != string.Empty) { cmbVoucherType.SelectedValue = dtblSalesReturnMaster.Rows[0]["SMVoucherTypeId"].ToString(); } else { cmbVoucherType.SelectedValue = 0; } cmbInvoiceComboFill(); if (dtblSalesReturnMaster.Rows[0]["pricingLevelId"].ToString() != string.Empty) { cmbPricingLevel.SelectedValue = dtblSalesReturnMaster.Rows[0]["pricingLevelId"].ToString(); } if (dtblSalesReturnMaster.Rows[0]["salesAccount"].ToString() != string.Empty) { cmbSalesAccount.SelectedValue = dtblSalesReturnMaster.Rows[0]["salesAccount"].ToString(); } if (dtblSalesReturnMaster.Rows[0]["employeeId"].ToString() != string.Empty) { cmbSalesMan.SelectedValue = dtblSalesReturnMaster.Rows[0]["employeeId"].ToString(); } if (dtblSalesReturnMaster.Rows[0]["exchangeRateId"].ToString() != string.Empty) { cmbCurrency.SelectedValue = dtblSalesReturnMaster.Rows[0]["exchangeRateId"].ToString(); } txtNarration.Text = dtblSalesReturnMaster.Rows[0]["narration"].ToString(); txtLRNo.Text = dtblSalesReturnMaster.Rows[0]["lrNo"].ToString(); txtTransportationComp.Text = dtblSalesReturnMaster.Rows[0]["transportationCompany"].ToString(); if (dtblSalesReturnMaster.Rows[0]["salesMasterId"].ToString() != string.Empty && Convert.ToDecimal(dtblSalesReturnMaster.Rows[0]["salesMasterId"].ToString()) != 0) { cmbInvoiceNo.SelectedValue = dtblSalesReturnMaster.Rows[0]["salesMasterId"].ToString(); decinvoiceno = Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()); dtblSalesReturnMasterViewBySMID = spSalesReturnMaster.SalesReturnMasterViewBySalesMasterId(Convert.ToDecimal(dtblSalesReturnMaster.Rows[0]["salesMasterId"].ToString())); } isInvoiceFill = false; if (dtblSalesReturnMaster.Rows[0]["voucherTypeId"].ToString() != string.Empty) { decSalesReturnVoucherTypeId = Convert.ToDecimal(dtblSalesReturnMaster.Rows[0]["voucherTypeId"].ToString()); } TaxGridFill(); if (cmbInvoiceNo.SelectedValue != null) { infoSalesMaster = spSalesMaster.SalesMasterViewBySalesMasterId(Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString())); } DataTable dtblSalesReturnDetails = new DataTable(); dtblSalesReturnDetails = spSalesReturnDetails.SalesReturnDetailsViewBySalesReturnMasterId(salesReturnMasterId); dtblSalesInvoice = dtblSalesReturnDetails; foreach (DataRow drowDetails in dtblSalesReturnDetails.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(); DataTable dtbl = spSalesDetails.SalesReturnGrideFillNewByProductId(Convert.ToDecimal(drowDetails["productId"].ToString())); foreach (DataRow drowDetails1 in dtbl.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 (dtblSalesReturnMaster.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 = spSalesReturnMaster.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) { dtblTaxGride = spSalesReturnBillTax.TaxDetailsViewBySalesReturnMasterId(salesReturnMasterId); foreach (DataRow item1 in dtblTaxGride.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(dtblSalesReturnMaster.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); } }