/// <summary> /// Function to save an item into table /// </summary> public void Save() { ExchangeRateSP spExchangeRate = new ExchangeRateSP(); SalesReturnMasterSP spSalesReturnMaster = new SalesReturnMasterSP(); SalesReturnDetailsSP spSalesReturnDetails = new SalesReturnDetailsSP(); StockPostingSP spStockPosting = new StockPostingSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); PartyBalanceSP spPartyBalance = new PartyBalanceSP(); UnitConvertionSP spUnitConvertion = new UnitConvertionSP(); UnitSP spUnit = new UnitSP(); try { if (txtReturnNo.Text.Trim() == string.Empty) { MessageBox.Show("Enter return no", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); txtReturnNo.Focus(); } else if (spSalesReturnMaster.SalesReturnNumberCheckExistence(txtReturnNo.Text.Trim(), 0, decSalesReturnVoucherTypeId) == true && btnSave.Text == "Save") { Messages.InformationMessage("Return number already exist"); txtReturnNo.Focus(); } //else if ((txtReturnNo .Text!=ManualReturnNo)&&(spSalesReturnMaster.SalesReturnNumberCheckExistence(txtReturnNo.Text.Trim(), 0, decSalesReturnVoucherTypeId) == true && btnSave.Text == "Update")) //{ // Messages.InformationMessage("Return number already exist"); // txtReturnNo.Focus(); //} else if (txtDate.Text == "") { MessageBox.Show("Select a date in between financial year", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); txtDate.Focus(); } else if (cmbCashOrParty.SelectedValue == null) { MessageBox.Show("Select cash/party", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); cmbCashOrParty.Focus(); } else if (cmbSalesAccount.SelectedValue == null) { MessageBox.Show("Select sales account", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); cmbSalesAccount.Focus(); } else if (cmbCurrency.SelectedValue == null) { MessageBox.Show("Select currency", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); cmbCurrency.Focus(); } else { if (isAutomatic) { if (strVoucherNo != string.Empty) { infoSalesReturnMaster.VoucherNo = strVoucherNo; } if (txtReturnNo.Text != string.Empty) { infoSalesReturnMaster.InvoiceNo = txtReturnNo.Text; } } else { infoSalesReturnMaster.VoucherNo = txtReturnNo.Text; infoSalesReturnMaster.InvoiceNo = txtReturnNo.Text; } if (decSalesReturnVoucherTypeId != 0) { infoSalesReturnMaster.VoucherTypeId = decSalesReturnVoucherTypeId; } if (decSalesReturnSuffixPrefixId != 0) { infoSalesReturnMaster.SuffixPrefixId = decSalesReturnSuffixPrefixId; } if (cmbCashOrParty.SelectedValue != null) { infoSalesReturnMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); } if (cmbInvoiceNo.SelectedValue != null) { infoSalesReturnMaster.SalesMasterId = Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()); } else { infoSalesReturnMaster.SalesMasterId = 0; } if (cmbSalesAccount.SelectedValue != null) { infoSalesReturnMaster.SalesAccount = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString()); } if (cmbPricingLevel.SelectedValue != null) { infoSalesReturnMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); } else { infoSalesReturnMaster.PricinglevelId = 0; } if (cmbSalesMan.SelectedValue != null) { infoSalesReturnMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); } else { infoSalesReturnMaster.EmployeeId = 0; } if (cmbCurrency.SelectedValue != null) { infoSalesReturnMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); decExchangeRate = spExchangeRate.ExchangeRateViewByExchangeRateId(infoSalesReturnMaster.ExchangeRateId); } infoSalesReturnMaster.Narration = txtNarration.Text.Trim(); infoSalesReturnMaster.UserId = PublicVariables._decCurrentUserId; infoSalesReturnMaster.LrNo = txtLRNo.Text.Trim(); infoSalesReturnMaster.TransportationCompany = txtTransportationComp.Text.Trim(); infoSalesReturnMaster.Date = Convert.ToDateTime(txtDate.Text); if (txtTotalAmount.Text != string.Empty) { infoSalesReturnMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); } if (txtGrandTotal.Text != string.Empty) { infoSalesReturnMaster.grandTotal = Convert.ToDecimal(txtGrandTotal.Text); } if (lblTaxAmount.Text != string.Empty) { infoSalesReturnMaster.TaxAmount = Convert.ToDecimal(lblTaxAmount.Text); } infoSalesReturnMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoSalesReturnMaster.Extra1 = string.Empty; infoSalesReturnMaster.Extra2 = string.Empty; if (txtBillDiscount.Text != string.Empty) { infoSalesReturnMaster.Discount = Convert.ToDecimal(txtBillDiscount.Text); } else { infoSalesReturnMaster.Discount = 0; } decimal decNetTotal = 0; decimal decGrandTotal = 0; string strQuantities = string.Empty; if (btnSave.Text == "Update") { infoSalesReturnMaster.SalesReturnMasterId = decSalesReturnMasterId; spSalesReturnMaster.SalesReturnMasterEdit(infoSalesReturnMaster); spLedgerPosting.LedgerPostingAndPartyBalanceDeleteByVoucherTypeIdAndLedgerIdAndVoucherNo(decSalesReturnVoucherTypeId, strVoucherNo, txtReturnNo.Text); spLedgerPosting.LedgerPostingAndPartyBalanceDeleteByVoucherTypeIdAndLedgerIdAndVoucherNo(decSalesReturnVoucherTypeId, strVoucherNo, txtReturnNo.Text); spStockPosting.StockPostingDeleteByVoucherTypeAndVoucherNo(strVoucherNo, decSalesReturnVoucherTypeId); spSalesReturnBillTax.SalesReturnBillTaxDeleteBySalesReturnMasterId(decSalesReturnMasterId); } else { decSalesReturnMasterId = spSalesReturnMaster.SalesReturnMasterAdd(infoSalesReturnMaster); } SalesReturnDetailsInfo infoSalesReturnDetailsInfo = new SalesReturnDetailsInfo(); infoSalesReturnDetailsInfo.Extra1 = string.Empty; infoSalesReturnDetailsInfo.Extra2 = string.Empty; if (btnSave.Text == "Update") { foreach (var strId in lstArrOfRemove) { decimal decDeleteId = Convert.ToDecimal(strId); spSalesReturnDetails.SalesReturnDetailsDelete(decDeleteId); } } foreach (DataGridViewRow DGVSalesReturn in dgvSalesReturn.Rows) { if (DGVSalesReturn.Cells["productId"].Value != null && DGVSalesReturn.Cells["productId"].Value.ToString() != string.Empty) { infoSalesReturnDetailsInfo.SalesReturnMasterId = decSalesReturnMasterId; infoSalesReturnDetailsInfo.ProductId = Convert.ToDecimal(DGVSalesReturn.Cells["productId"].Value.ToString()); if (DGVSalesReturn.Cells["dgvTextQty"].Value != null) { infoSalesReturnDetailsInfo.Qty = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextQty"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvTextRate"].Value != null) { infoSalesReturnDetailsInfo.Rate = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextRate"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvCmbUnit"].Value != null) { infoSalesReturnDetailsInfo.UnitId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbUnit"].Value.ToString()); } if (DGVSalesReturn.Cells["unitConversionId"].Value != null) { infoSalesReturnDetailsInfo.UnitConversionId = Convert.ToDecimal(DGVSalesReturn.Cells["unitConversionId"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvTextDiscountAmount"].Value != null) { infoSalesReturnDetailsInfo.Discount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextDiscountAmount"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvCmbTax"].Value != null) { infoSalesReturnDetailsInfo.TaxId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbTax"].Value.ToString()); } else { infoSalesReturnDetailsInfo.TaxId = 0; } if (DGVSalesReturn.Cells["dgvCmbBatch"].Value != null) { infoSalesReturnDetailsInfo.BatchId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbBatch"].Value.ToString()); } else { infoSalesReturnDetailsInfo.BatchId = 0; } if (DGVSalesReturn.Cells["dgvCmbBatch"].Value != null) { infoSalesReturnDetailsInfo.BatchId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbBatch"].Value.ToString()); } else { infoSalesReturnDetailsInfo.BatchId = 0; } if (DGVSalesReturn.Cells["dgvCmbGodown"].Value != null) { infoSalesReturnDetailsInfo.GodownId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbGodown"].Value.ToString()); } else { infoSalesReturnDetailsInfo.GodownId = 0; } if (DGVSalesReturn.Cells["dgvCmbRack"].Value != null) { infoSalesReturnDetailsInfo.RackId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbRack"].Value.ToString()); } else { infoSalesReturnDetailsInfo.RackId = 0; } if (DGVSalesReturn.Cells["dgvTextTaxAmount"].Value != null) { infoSalesReturnDetailsInfo.TaxAmount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextTaxAmount"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvTextGrossValue"].Value != null) { infoSalesReturnDetailsInfo.GrossAmount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextGrossValue"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvTextNetValue"].Value != null) { infoSalesReturnDetailsInfo.NetAmount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextNetValue"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvTextAmount1"].Value != null) { infoSalesReturnDetailsInfo.Amount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextAmount1"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvSNo"].Value != null) { infoSalesReturnDetailsInfo.SlNo = Convert.ToInt32(DGVSalesReturn.Cells["dgvSNo"].Value.ToString()); } if (DGVSalesReturn.Cells["salesDetailsId"].Value != null && cmbInvoiceNo.SelectedValue != null) { infoSalesReturnDetailsInfo.SalesDetailsId = Convert.ToDecimal(DGVSalesReturn.Cells["salesDetailsId"].Value.ToString()); } else { infoSalesReturnDetailsInfo.SalesDetailsId = 0; } if (DGVSalesReturn.Cells["salesReturnDetailsId"].Value != null) { infoSalesReturnDetailsInfo.SalesReturnDetailsId = Convert.ToDecimal(DGVSalesReturn.Cells["salesReturnDetailsId"].Value.ToString()); spSalesReturnDetails.SalesReturnDetailsEdit(infoSalesReturnDetailsInfo); } else { decSalesReturnDetailId = spSalesReturnDetails.SalesReturnDetailsAdd(infoSalesReturnDetailsInfo); } StockPostingInfo infoStockPosting = new StockPostingInfo(); infoStockPosting.Date = infoSalesReturnMaster.Date; if (DGVSalesReturn.Cells["voucherTypeId"].Value != null) { infoStockPosting.VoucherTypeId = Convert.ToDecimal(DGVSalesReturn.Cells["voucherTypeId"].Value.ToString()); decAgainstVoucherTypeId = infoStockPosting.VoucherTypeId; infoStockPosting.AgainstVoucherTypeId = decSalesReturnVoucherTypeId; } else { infoStockPosting.VoucherTypeId = decSalesReturnVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; } if (DGVSalesReturn.Cells["voucherNo"].Value != null) { infoStockPosting.VoucherNo = DGVSalesReturn.Cells["voucherNo"].Value.ToString(); strAgainstVoucherNo = infoStockPosting.VoucherNo; infoStockPosting.AgainstVoucherNo = strVoucherNo; } else { infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.AgainstVoucherNo = "NA"; } if (DGVSalesReturn.Cells["invoiceNo"].Value != null) { infoStockPosting.InvoiceNo = DGVSalesReturn.Cells["invoiceNo"].Value.ToString(); strAgainstInvoiceNo = infoStockPosting.InvoiceNo; infoStockPosting.AgainstInvoiceNo = txtReturnNo.Text.Trim(); } else { infoStockPosting.InvoiceNo = txtReturnNo.Text; infoStockPosting.AgainstInvoiceNo = "NA"; } infoStockPosting.ProductId = infoSalesReturnDetailsInfo.ProductId; infoStockPosting.BatchId = infoSalesReturnDetailsInfo.BatchId; infoStockPosting.UnitId = infoSalesReturnDetailsInfo.UnitId; infoStockPosting.GodownId = infoSalesReturnDetailsInfo.GodownId; infoStockPosting.RackId = infoSalesReturnDetailsInfo.RackId; if (infoSalesReturnDetailsInfo.ProductId != 0 && infoSalesReturnDetailsInfo.UnitId != 0) { decimal decUnitConvertionRate = 0; infoProduct = spProduct.ProductView(infoSalesReturnDetailsInfo.ProductId); DataTable dtbl = spUnitConvertion.DGVUnitConvertionRateByUnitId(infoSalesReturnDetailsInfo.UnitId, infoProduct.ProductName); foreach (DataRow drowDetails in dtbl.Rows) { decUnitConvertionRate = Convert.ToDecimal(drowDetails["conversionRate"].ToString()); } strQuantities = spUnit.UnitConversionCheck(infoSalesReturnDetailsInfo.UnitId, infoSalesReturnDetailsInfo.ProductId); if (strQuantities != string.Empty) { infoStockPosting.InwardQty = infoSalesReturnDetailsInfo.Qty / decUnitConvertionRate; } else { infoStockPosting.InwardQty = infoSalesReturnDetailsInfo.Qty; } } infoStockPosting.OutwardQty = 0; infoStockPosting.Rate = infoSalesReturnDetailsInfo.Rate; infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; spStockPosting.StockPostingAdd(infoStockPosting); } } decGrandTotal = Convert.ToDecimal(txtGrandTotal.Text); decNetTotal = TotalNetAmountForLedgerPosting(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); infoLedgerPosting.Date = infoSalesReturnMaster.Date; infoLedgerPosting.ChequeDate = infoSalesReturnMaster.Date; infoLedgerPosting.ChequeNo = String.Empty; infoLedgerPosting.VoucherTypeId = infoSalesReturnMaster.VoucherTypeId; infoLedgerPosting.VoucherNo = infoSalesReturnMaster.VoucherNo; infoLedgerPosting.LedgerId = infoSalesReturnMaster.LedgerId; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = (decGrandTotal * decExchangeRate); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.InvoiceNo = infoSalesReturnMaster.InvoiceNo; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); infoLedgerPosting.LedgerId = infoSalesReturnMaster.SalesAccount; infoLedgerPosting.Debit = (decNetTotal * decExchangeRate); infoLedgerPosting.Credit = 0; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); if (Convert.ToDecimal(txtBillDiscount.Text == string.Empty ? "0" : txtBillDiscount.Text) > 0) { infoLedgerPosting.LedgerId = 8; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = (Convert.ToDecimal(txtBillDiscount.Text) * decExchangeRate); spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } LedegrPostingForTax(); PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); infoPartyBalance.Date = infoSalesReturnMaster.Date; infoPartyBalance.LedgerId = infoSalesReturnMaster.LedgerId; if (decAgainstVoucherTypeId != 0) { infoPartyBalance.VoucherTypeId = decAgainstVoucherTypeId; infoPartyBalance.VoucherNo = strAgainstVoucherNo; infoPartyBalance.InvoiceNo = strAgainstInvoiceNo; infoPartyBalance.AgainstVoucherTypeId = infoSalesReturnMaster.VoucherTypeId; infoPartyBalance.AgainstVoucherNo = infoSalesReturnMaster.VoucherNo; infoPartyBalance.AgainstInvoiceNo = infoSalesReturnMaster.InvoiceNo; infoPartyBalance.ReferenceType = "Against"; } else { infoPartyBalance.VoucherTypeId = infoSalesReturnMaster.VoucherTypeId; infoPartyBalance.VoucherNo = infoSalesReturnMaster.VoucherNo; infoPartyBalance.InvoiceNo = infoSalesReturnMaster.InvoiceNo; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "NA"; infoPartyBalance.AgainstInvoiceNo = "NA"; infoPartyBalance.ReferenceType = "New"; } infoPartyBalance.Credit = infoSalesReturnMaster.TotalAmount; infoPartyBalance.Debit = 0; infoPartyBalance.CreditPeriod = 0; infoPartyBalance.ExchangeRateId = infoSalesReturnMaster.ExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; spPartyBalance.PartyBalanceAdd(infoPartyBalance); SalesReturnBillTaxInfo infoSalesReturnBillTax = new SalesReturnBillTaxInfo(); foreach (DataGridViewRow item in dgvSalesReturn2.Rows) { if (item.Cells["dgvTextTaxId"].Value != null) { infoSalesReturnBillTax.SalesReturnMasterId = decSalesReturnMasterId; infoSalesReturnBillTax.TaxId = Convert.ToDecimal(item.Cells["dgvTextTaxId"].Value.ToString()); infoSalesReturnBillTax.TaxAmount = Convert.ToDecimal(item.Cells["dgvTextAmount"].Value.ToString()); infoSalesReturnBillTax.Extra1 = string.Empty; infoSalesReturnBillTax.Extra2 = string.Empty; spSalesReturnBillTax.SalesReturnBillTaxAdd(infoSalesReturnBillTax); } } if (btnSave.Text == "Save") { Messages.SavedMessage(); if (cbxPrintAfterSave.Checked == true) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesReturnMasterId); } else { Print(decSalesReturnMasterId); } } clear(); } else { Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked == true) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesReturnMasterId); } else { Print(decSalesReturnMasterId); } } this.Close(); } } } catch (Exception ex) { MessageBox.Show("SR36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Delete Function /// </summary> public void Delete() { try { DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP(); DeliveryNoteDetailsSP spDeliveryNoteDetails = new DeliveryNoteDetailsSP(); StockPostingSP spStockPosting = new StockPostingSP(); if (!spDeliveryNoteMaster.DeliveryNoteCheckReferenceInSalesInvoice(decDelivryNoteIdToEdit)) { decimal decResult1 = 0; decimal decResult2 = spDeliveryNoteMaster.DeliveryNoteMasterDelete(decDelivryNoteIdToEdit); for (int inI = 0; inI < dgvProduct.Rows.Count - 1; inI++) { if (Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value) != 0) { decResult1 = spDeliveryNoteDetails.DeliveryNoteDetailsDelete(Convert.ToDecimal(dgvProduct.Rows[0].Cells["dgvtxtDetailsId"].Value.ToString())); } } spStockPosting.StockPostingDeleteByVoucherTypeAndVoucherNo(strVoucherNo, decDeliveryNoteVoucherTypeId); if (decResult2 > 0) { Messages.DeletedMessage(); } else { Messages.ReferenceExistsMessage(); } if (frmDeliveryNoteRegisterObj != null) { this.Close(); frmDeliveryNoteRegisterObj.GridFill(); } if (frmDeliveryNoteReportObj != null) { this.Close(); frmDeliveryNoteReportObj.GridFill(); } if (frmDayBookObj != null) { this.Close(); } if (objVoucherSearch != null) { this.Close(); } if (objVoucherProduct != null) { this.Close(); } } else { Messages.ReferenceExistsMessage(); } } catch (Exception ex) { MessageBox.Show("DN42:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the voucher details for edit /// </summary> public void MaterialReceiptDetailsEditFill() { ProductInfo infoProduct = new ProductInfo(); MaterialReceiptDetailsInfo infoMaterialReceiptDetails = new MaterialReceiptDetailsInfo(); StockPostingSP spstockposting = new StockPostingSP(); MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP(); MaterialReceiptDetailsSP spMaterialReceiptDetails = new MaterialReceiptDetailsSP(); ProductSP spproduct = new ProductSP(); try { for (int inI = 0; inI < dgvProduct.Rows.Count - 1; inI++) { decimal decStatus = spMaterialReceiptMaster.MaterialReceiptDetailsReferenceCheck(decMaterialReceiptDetailId); if (decStatus == 1) { dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].ReadOnly = true; dgvProduct.Rows[inI].Cells["dgvtxtProductName"].ReadOnly = true; dgvProduct.Rows[inI].Cells["dgvcmbUnit"].ReadOnly = true; dgvProduct.Rows[inI].Cells["dgvtxtBarcode"].ReadOnly = true; dgvProduct.Rows[inI].Cells["dgvCmbRack"].ReadOnly = true; dgvProduct.Rows[inI].Cells["dgvcmbGodown"].ReadOnly = true; dgvProduct.Rows[inI].Cells["dgvtxtRate"].ReadOnly = true; } if (dgvProduct.Rows[inI].Cells["dgvtxtProductName"].Value != null) { if (dgvProduct.Rows[inI].Cells["dgvtxtMaterialReceiptdetailsId"].Value == null || dgvProduct.Rows[inI].Cells["dgvtxtMaterialReceiptdetailsId"].Value.ToString() == string.Empty) { infoMaterialReceiptDetails.MaterialReceiptMasterId = decMaterialReceiptMasterId; infoProduct = spproduct.ProductViewByCode(dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoMaterialReceiptDetails.ProductId = infoProduct.ProductId; if (dgvProduct.Rows[inI].Cells["dgvtxtPurchaseOrderDetailsId"].Value != null) { infoMaterialReceiptDetails.OrderDetailsId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtPurchaseOrderDetailsId"].Value.ToString()); } else infoMaterialReceiptDetails.OrderDetailsId = 0; infoMaterialReceiptDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); infoMaterialReceiptDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); infoMaterialReceiptDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value); if (dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString() != string.Empty) { infoMaterialReceiptDetails.GodownId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString()); } else { infoMaterialReceiptDetails.GodownId = 1; } if (dgvProduct.Rows[inI].Cells["dgvCmbRack"].Value != null && dgvProduct.Rows[inI].Cells["dgvCmbRack"].Value.ToString() != string.Empty) { infoMaterialReceiptDetails.RackId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvCmbRack"].Value.ToString()); } else { infoMaterialReceiptDetails.RackId = 1; } if (dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { infoMaterialReceiptDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString()); } else { infoMaterialReceiptDetails.BatchId = 1; } infoMaterialReceiptDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoMaterialReceiptDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoMaterialReceiptDetails.Slno = Convert.ToInt32(dgvProduct.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); infoMaterialReceiptDetails.Extra1 = string.Empty; infoMaterialReceiptDetails.Exta2 = string.Empty; infoMaterialReceiptDetails.ExtraDate = Convert.ToDateTime(DateTime.Now); spMaterialReceiptDetails.MaterialReceiptDetailsAdd(infoMaterialReceiptDetails); } else { infoMaterialReceiptDetails.MaterialReceiptMasterId = decMaterialReceiptMasterId; infoMaterialReceiptDetails.MaterialReceiptDetailsId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtMaterialReceiptdetailsId"].Value); infoProduct = spproduct.ProductViewByCode(dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoMaterialReceiptDetails.ProductId = infoProduct.ProductId; if (dgvProduct.Rows[inI].Cells["dgvtxtPurchaseOrderDetailsId"].Value != null) { infoMaterialReceiptDetails.OrderDetailsId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtPurchaseOrderDetailsId"].Value.ToString()); } else infoMaterialReceiptDetails.OrderDetailsId = 0; infoMaterialReceiptDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); infoMaterialReceiptDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); infoMaterialReceiptDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value); infoMaterialReceiptDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); if (dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString() != string.Empty) { infoMaterialReceiptDetails.GodownId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString()); } else { infoMaterialReceiptDetails.GodownId = 1; } if (dgvProduct.Rows[inI].Cells["dgvCmbRack"].Value != null && dgvProduct.Rows[inI].Cells["dgvCmbRack"].Value.ToString() != string.Empty) { infoMaterialReceiptDetails.RackId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvCmbRack"].Value.ToString()); } else { infoMaterialReceiptDetails.RackId = 1; } if (dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { infoMaterialReceiptDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString()); } else { infoMaterialReceiptDetails.BatchId = 1; } infoMaterialReceiptDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoMaterialReceiptDetails.Slno = Convert.ToInt32(dgvProduct.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); infoMaterialReceiptDetails.Extra1 = string.Empty; infoMaterialReceiptDetails.Exta2 = string.Empty; infoMaterialReceiptDetails.ExtraDate = Convert.ToDateTime(DateTime.Now); spMaterialReceiptDetails.MaterialReceiptDetailsEdit(infoMaterialReceiptDetails); } StockPostingInfo infoStockPosting = new StockPostingInfo(); infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); infoStockPosting.ProductId = infoMaterialReceiptDetails.ProductId; infoStockPosting.BatchId = infoMaterialReceiptDetails.BatchId; infoStockPosting.UnitId = infoMaterialReceiptDetails.UnitId; infoStockPosting.GodownId = infoMaterialReceiptDetails.GodownId; infoStockPosting.RackId = infoMaterialReceiptDetails.RackId; if (cmbOrderNo.SelectedValue != null) { if (dgvProduct.Rows[inI].Cells["dgvtxtvoucherNo"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtvoucherNo"].Value.ToString() != string.Empty && dgvProduct.Rows[inI].Cells["dgvtxtvoucherNo"].Value.ToString() != "NA") { infoStockPosting.VoucherNo = Convert.ToString(dgvProduct.Rows[inI].Cells["dgvtxtvoucherNo"].Value.ToString()); infoStockPosting.AgainstVoucherNo = strVoucherNo; } else { infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.AgainstVoucherNo = "NA"; } if (dgvProduct.Rows[inI].Cells["dgvtxtinvoiceNo"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtinvoiceNo"].Value.ToString() != string.Empty && dgvProduct.Rows[inI].Cells["dgvtxtinvoiceNo"].Value.ToString() != "NA") { infoStockPosting.InvoiceNo = Convert.ToString(dgvProduct.Rows[inI].Cells["dgvtxtinvoiceNo"].Value.ToString()); infoStockPosting.AgainstInvoiceNo = txtReceiptNo.Text; } else { infoStockPosting.InvoiceNo = txtReceiptNo.Text; infoStockPosting.AgainstInvoiceNo = "NA"; } if (dgvProduct.Rows[inI].Cells["dgvtxtvouchertypeId"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtvouchertypeId"].Value.ToString() != string.Empty && Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtvouchertypeId"].Value.ToString()) != 0) { infoStockPosting.VoucherTypeId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtvouchertypeId"].Value.ToString()); infoStockPosting.AgainstVoucherTypeId = decMaterialReceiptVoucherTypeId; } else { infoStockPosting.VoucherTypeId = decMaterialReceiptVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; } } else { infoStockPosting.InvoiceNo = txtReceiptNo.Text; infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = decMaterialReceiptVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstInvoiceNo = "NA"; } spstockposting.StockPostingDeleteByVoucherTypeAndVoucherNo(strVoucherNo, decMaterialReceiptVoucherTypeId); infoStockPosting.InwardQty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); infoStockPosting.OutwardQty = 0; infoStockPosting.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; spstockposting.StockPostingAdd(infoStockPosting); isEdit = true; } } if (isEdit) { cmbCashOrParty.Enabled = true; cmbOrderNo.Enabled = true; cmbcurrency.Enabled = true; txtDate.Enabled = true; cmbVoucherType.Enabled = true; } } catch (Exception ex) { MessageBox.Show("MR37:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }