/// <summary> /// Function to get particular values from PurchaseReturnMaster table based on the parameter /// </summary> /// <param name="purchaseReturnMasterId"></param> /// <returns></returns> public PurchaseReturnMasterInfo PurchaseReturnMasterView(decimal purchaseReturnMasterId) { PurchaseReturnMasterInfo purchasereturnmasterinfo = new PurchaseReturnMasterInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("PurchaseReturnMasterView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@purchaseReturnMasterId", SqlDbType.Decimal); sprmparam.Value = purchaseReturnMasterId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { purchasereturnmasterinfo.PurchaseReturnMasterId = Convert.ToDecimal(sdrreader["purchaseReturnMasterId"].ToString()); purchasereturnmasterinfo.VoucherNo = sdrreader["voucherNo"].ToString(); purchasereturnmasterinfo.InvoiceNo = sdrreader["invoiceNo"].ToString(); purchasereturnmasterinfo.SuffixPrefixId = Convert.ToDecimal(sdrreader["suffixPrefixId"].ToString()); purchasereturnmasterinfo.VoucherTypeId = Convert.ToDecimal(sdrreader["voucherTypeId"].ToString()); purchasereturnmasterinfo.Date = Convert.ToDateTime(sdrreader["date"].ToString()); purchasereturnmasterinfo.LedgerId = Convert.ToDecimal(sdrreader["ledgerId"].ToString()); purchasereturnmasterinfo.Discount = Convert.ToDecimal(sdrreader["discount"].ToString()); purchasereturnmasterinfo.Narration = sdrreader["narration"].ToString(); purchasereturnmasterinfo.PurchaseAccount = Convert.ToDecimal(sdrreader["purchaseAccount"].ToString()); purchasereturnmasterinfo.TotalTax = Convert.ToDecimal(sdrreader["totalTax"].ToString()); purchasereturnmasterinfo.TotalAmount = Convert.ToDecimal(sdrreader["totalAmount"].ToString()); purchasereturnmasterinfo.GrandTotal = Convert.ToDecimal(sdrreader["grandTotal"].ToString()); purchasereturnmasterinfo.UserId = Convert.ToDecimal(sdrreader["userId"].ToString()); purchasereturnmasterinfo.LrNo = sdrreader["lrNo"].ToString(); purchasereturnmasterinfo.TransportationCompany = sdrreader["transportationCompany"].ToString(); purchasereturnmasterinfo.FinancialYearId = Convert.ToDecimal(sdrreader["financialYearId"].ToString()); purchasereturnmasterinfo.PurchaseMasterId = Convert.ToDecimal(sdrreader["purchaseMasterId"].ToString()); purchasereturnmasterinfo.ExchangeRateId = Convert.ToDecimal(sdrreader["exchangeRateId"].ToString()); purchasereturnmasterinfo.ExtraDate = Convert.ToDateTime(sdrreader["extraDate"].ToString()); purchasereturnmasterinfo.Extra1 = sdrreader["extra1"].ToString(); purchasereturnmasterinfo.Extra2 = sdrreader["extra2"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(purchasereturnmasterinfo); }
/// <summary> /// Function for print data /// </summary> /// <param name="decPurchaseReturnMasterId"></param> public void Print(decimal decPurchaseReturnMasterId) { try { PurchaseReturnMasterInfo infoPurchaseReturnMaster = new PurchaseReturnMasterInfo(); PurchaseReturnMasterSP SPPurchaseReturnMaster = new PurchaseReturnMasterSP(); DataSet dsPurchaseReturn = SPPurchaseReturnMaster.PurchaseReturnPrinting(decPurchaseReturnMasterId, 1, infoPurchaseReturnMaster.PurchaseMasterId); frmReport frmReport = new frmReport(); frmReport.MdiParent = formMDI.MDIObj; frmReport.PurchaseReturnPrinting(dsPurchaseReturn); } catch (Exception ex) { MessageBox.Show("PR:57" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Delete /// </summary> public void Delete() { try { StockPostingSP spStockPosting = new StockPostingSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); PurchaseMasterSP SPPurchaseMaster = new PurchaseMasterSP(); PurchaseReturnMasterSP SPPurchaseReturnMaster = new PurchaseReturnMasterSP(); PurchaseMasterInfo infoPurchaseMaster = new PurchaseMasterInfo(); PurchaseReturnMasterInfo infoPurchaseReturnMaster = new PurchaseReturnMasterInfo(); infoPurchaseReturnMaster = SPPurchaseReturnMaster.PurchaseReturnMasterView(decPurchaseReturnMasterId); if (infoPurchaseReturnMaster.PurchaseMasterId == 0) { spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(0, "NA", infoPurchaseReturnMaster.VoucherNo, infoPurchaseReturnMaster.VoucherTypeId); } if (infoPurchaseReturnMaster.PurchaseMasterId != 0) { infoPurchaseMaster = SPPurchaseMaster.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId); spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(infoPurchaseMaster.VoucherTypeId, infoPurchaseMaster.VoucherNo, strVoucherNo, infoPurchaseReturnMaster.VoucherTypeId); } spLedgerPosting.LedgerPostingAndPartyBalanceDeleteByVoucherTypeIdAndLedgerIdAndVoucherNo(decPurchaseReturnVoucherTypeId, strVoucherNo, txtReturnNo.Text); SPPurchaseReturnMaster.PurchaseReturnMasterAndDetailsDelete(decPurchaseReturnMasterId); Messages.DeletedMessage(); if (frmPurchaseReturnRegisterObj != null) { this.Close(); frmPurchaseReturnRegisterObj.GridFill(); } if (ObjPurchaseReturnReport != null) { this.Close(); ObjPurchaseReturnReport.PurchaseReturnReportGridFill(); } if (frmLedgerDetailsObj != null) { this.Close(); frmLedgerDetailsObj.LedgerDetailsView(); } if (objVoucherSearch != null) { this.Close(); objVoucherSearch.GridFill(); } if (frmDayBookObj != null) { this.Close(); } } catch (Exception ex) { MessageBox.Show("PR:50 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Save and Edit /// </summary> public void SaveOrEdit() { try { PurchaseMasterSP SPPurchaseMaster = new PurchaseMasterSP(); PurchaseReturnMasterSP SPPurchaseReturnMaster = new PurchaseReturnMasterSP(); PurchaseReturnDetailsSP SPPurchaseReturnDetails = new PurchaseReturnDetailsSP(); PurchaseReturnDetailsInfo infoPurchaseReturnDetails = new PurchaseReturnDetailsInfo(); StockPostingInfo infoStockPosting = new StockPostingInfo(); StockPostingSP spStockPosting = new StockPostingSP(); UnitConvertionSP SPUnitConversion = new UnitConvertionSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateSP spExchangeRate = new ExchangeRateSP(); PartyBalanceSP spPartyBalance = new PartyBalanceSP(); PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerSP spAccountLedger = new AccountLedgerSP(); PurchaseReturnBilltaxInfo infoPurchaseReturnBillTax = new PurchaseReturnBilltaxInfo(); PurchaseReturnBilltaxSP spPurchaseReturnBillTax = new PurchaseReturnBilltaxSP(); SettingsSP spSettings = new SettingsSP(); UnitSP spUnit = new UnitSP(); DataTable dtblPurchaseMasterViewById = new DataTable(); string strAgainstVoucherNo = string.Empty; string strAgainstInvoiceNo = string.Empty; decimal decPurchaseReturnMasterIds = 0; decimal decPurchaseMasterId = 0; decimal decDiscount = 0; decimal decExchangeRate = 0; decimal decDis = 0; if (isAutomatic) { if (strVoucherNo != string.Empty) { infoPurchaseReturnMaster.VoucherNo = strVoucherNo; } if (txtReturnNo.Text != string.Empty) { infoPurchaseReturnMaster.InvoiceNo = txtReturnNo.Text; } } else { infoPurchaseReturnMaster.VoucherNo = strVoucherNo; infoPurchaseReturnMaster.InvoiceNo = txtReturnNo.Text; } if (decPurchaseReturnVoucherTypeId != 0) { infoPurchaseReturnMaster.VoucherTypeId = decPurchaseReturnVoucherTypeId; } infoPurchaseReturnMaster.SuffixPrefixId = (decPurchaseReturnSuffixPrefixId != 0) ? decPurchaseReturnSuffixPrefixId : 0; infoPurchaseReturnMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoPurchaseReturnMaster.PurchaseAccount = Convert.ToDecimal(cmbPurchaseAccount.SelectedValue.ToString()); if (cmbInvoiceNo.SelectedValue != null && cmbInvoiceNo.Visible == true) { infoPurchaseReturnMaster.PurchaseMasterId = Convert.ToDecimal((cmbInvoiceNo.SelectedValue.ToString())); decPurchaseMasterId = Convert.ToDecimal((cmbInvoiceNo.SelectedValue.ToString())); } else { infoPurchaseReturnMaster.PurchaseMasterId = 0; } infoPurchaseReturnMaster.ExchangeRateId = (cmbCurrency.SelectedValue != null) ? Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()) : 0; infoPurchaseReturnMaster.Narration = txtNarration.Text.Trim(); infoPurchaseReturnMaster.UserId = PublicVariables._decCurrentUserId; infoPurchaseReturnMaster.LrNo = txtLrlNo.Text.Trim(); infoPurchaseReturnMaster.TransportationCompany = txtTransportationCompany.Text.Trim(); infoPurchaseReturnMaster.Date = Convert.ToDateTime(txtDate.Text); infoPurchaseReturnMaster.TotalAmount = (txtTotalAmount.Text != string.Empty) ? Convert.ToDecimal(txtTotalAmount.Text) : 0; infoPurchaseReturnMaster.TotalTax = (lblTaxAmount.Text != string.Empty) ? Convert.ToDecimal(lblTaxAmount.Text) : 0; infoPurchaseReturnMaster.Discount = (txtBillDiscount.Text != string.Empty) ? Convert.ToDecimal(txtBillDiscount.Text) : 0; infoPurchaseReturnMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPurchaseReturnMaster.Extra1 = string.Empty; infoPurchaseReturnMaster.Extra2 = string.Empty; infoPurchaseReturnMaster.ExtraDate = DateTime.Now; infoPurchaseReturnMaster.GrandTotal = (txtGrandTotal.Text != string.Empty) ? Convert.ToDecimal(txtGrandTotal.Text) : 0; if (btnSave.Text == "Save") { decPurchaseReturnMasterIds = SPPurchaseReturnMaster.PurchaseReturnMasterAddWithReturnIdentity(infoPurchaseReturnMaster); } else { infoPurchaseReturnMaster.PurchaseReturnMasterId = decPurchaseReturnMasterId; decExchangeRate = spExchangeRate.ExchangeRateViewByExchangeRateId(infoPurchaseReturnMaster.ExchangeRateId); SPPurchaseReturnMaster.PurchaseReturnMasterEdit(infoPurchaseReturnMaster); infoPurchaseMaster = SPPurchaseMaster.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId); spLedgerPosting.LedgerPostDelete(strVoucherNo, decPurchaseReturnVoucherTypeId); spAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPurchaseReturnVoucherTypeId); } infoLedgerPosting.Date = infoPurchaseReturnMaster.Date; infoLedgerPosting.VoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId; infoLedgerPosting.VoucherNo = infoPurchaseReturnMaster.VoucherNo; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.LedgerId = infoPurchaseReturnMaster.PurchaseAccount; infoLedgerPosting.Debit = 0; if (btnSave.Text == "Save") { infoLedgerPosting.Credit = TotalNetAmountCalculation() * spExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.ExtraDate = DateTime.Now; } else { infoLedgerPosting.Credit = TotalNetAmountCalculation(); } spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); infoLedgerPosting.LedgerId = infoPurchaseReturnMaster.LedgerId; if (btnSave.Text == "Save") { infoLedgerPosting.Debit = Convert.ToDecimal(txtGrandTotal.Text) * spExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.ExtraDate = DateTime.Now; } else { infoLedgerPosting.Debit = Convert.ToDecimal(txtGrandTotal.Text); } infoLedgerPosting.Credit = 0; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); foreach (DataGridViewRow dgvrow in dgvPurchaseReturnTax.Rows) { if (dgvrow.Cells["dgvtxtTaxId"].Value != null && dgvrow.Cells["dgvtxtTaxId"].Value.ToString() != string.Empty) { infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvtxtledgerId"].Value.ToString()); infoLedgerPosting.Credit = (dgvrow.Cells["dgvtxtAmounts"].Value == null) ? 0 : Convert.ToDecimal(dgvrow.Cells["dgvtxtAmounts"].Value.ToString()); infoLedgerPosting.Debit = 0; infoLedgerPosting.ExtraDate = DateTime.Now; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } if (txtBillDiscount.Text.Trim() != string.Empty) { decDis = Convert.ToDecimal(txtBillDiscount.Text); } if (decDis >= 0) { infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decDis; infoLedgerPosting.LedgerId = 9; infoLedgerPosting.ExtraDate = DateTime.Now; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } if (btnSave.Text == "Update") { infoPurchaseReturnMaster = SPPurchaseReturnMaster.PurchaseReturnMasterView(decPurchaseReturnMasterId); if (infoPurchaseReturnMaster.PurchaseMasterId == 0) { spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(0, "NA", infoPurchaseReturnMaster.VoucherNo, infoPurchaseReturnMaster.VoucherTypeId); } if (infoPurchaseReturnMaster.PurchaseMasterId != 0) { infoPurchaseMaster = SPPurchaseMaster.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId); spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(infoPurchaseMaster.VoucherTypeId, strInvoiceNo, strVoucherNo, infoPurchaseReturnMaster.VoucherTypeId); } } foreach (DataGridViewRow dgvrow in dgvPurchaseReturn.Rows) { if (dgvrow.Cells["dgvtxtProductId"].Value != null && dgvrow.Cells["dgvtxtProductId"].Value.ToString() != string.Empty) { infoPurchaseReturnDetails.ExtraDate = DateTime.Now; infoPurchaseReturnDetails.Extra1 = string.Empty; infoPurchaseReturnDetails.Extra2 = string.Empty; infoPurchaseReturnDetails.PurchaseReturnMasterId = (btnSave.Text == "Save") ? decPurchaseReturnMasterIds : decPurchaseReturnMasterId; infoPurchaseReturnDetails.ProductId = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtproductId"].Value)); infoPurchaseReturnDetails.Qty = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtqty"].Value)); infoPurchaseReturnDetails.Rate = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtrate"].Value)); if (btnSave.Text == "Save") { infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); infoPurchaseReturnDetails.UnitConversionId = SPUnitConversion.UnitconversionIdViewByUnitIdAndProductId(infoPurchaseReturnDetails.UnitId, infoPurchaseReturnDetails.ProductId); } else { if (Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value) == 0) { try { infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); } catch { infoPurchaseReturnDetails.UnitId = spUnit.UnitIdByUnitName(Convert.ToString(dgvrow.Cells["dgvcmbUnit"].Value.ToString())); } infoPurchaseReturnDetails.UnitConversionId = SPUnitConversion.UnitconversionIdViewByUnitIdAndProductId(infoPurchaseReturnDetails.UnitId, infoPurchaseReturnDetails.ProductId); } else { try { infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); } catch { infoPurchaseReturnDetails.UnitId = spUnit.UnitIdByUnitName(Convert.ToString(dgvrow.Cells["dgvcmbUnit"].Value.ToString())); } } infoPurchaseReturnDetails.UnitConversionId = Convert.ToDecimal(dgvrow.Cells["dgvtxtUnitConversionId"].Value); } infoPurchaseReturnDetails.Discount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtdiscount"].Value)); if (dgvrow.Cells["dgvcmbTax"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbTax"].Value) != string.Empty && dgvrow.Cells["dgvcmbTax"].Value as string != "NA") { infoPurchaseReturnDetails.TaxId = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvcmbTax"].Value)); if (strTaxComboFill != string.Empty) { infoPurchaseReturnDetails.TaxAmount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtTaxAmount"].Value)); } } else { infoPurchaseReturnDetails.TaxId = 0; } if (dgvrow.Cells["dgvcmbBatch"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbBatch"].Value) != string.Empty) { infoPurchaseReturnDetails.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value); } else { infoPurchaseReturnDetails.GodownId = 0; } if (dgvrow.Cells["dgvcmbGodown"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbGodown"].Value) != string.Empty) { infoPurchaseReturnDetails.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value); } else { infoPurchaseReturnDetails.RackId = 0; } if (dgvrow.Cells["dgvcmbRack"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbRack"].Value) != string.Empty) { infoPurchaseReturnDetails.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value); } infoPurchaseReturnDetails.GrossAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtgrossValue"].Value.ToString()); infoPurchaseReturnDetails.NetAmount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtNetAmount"].Value)); infoPurchaseReturnDetails.Amount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtAmount"].Value)); infoPurchaseReturnDetails.SlNo = Convert.ToInt32(Convert.ToString(dgvrow.Cells["dgvtxtSlNo"].Value)); infoPurchaseReturnDetails.PurchaseDetailsId = (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value != null) ? Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value)) : 0; if (dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value != null) { if (dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString() == "0" || dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString() == string.Empty) { SPPurchaseReturnDetails.PurchaseReturnDetailsAddWithReturnIdentity(infoPurchaseReturnDetails); } else { infoPurchaseReturnDetails.PurchaseReturnDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString()); SPPurchaseReturnDetails.PurchaseReturnDetailsEdit(infoPurchaseReturnDetails); } } else { SPPurchaseReturnDetails.PurchaseReturnDetailsAddWithReturnIdentity(infoPurchaseReturnDetails); } if (btnSave.Text == "Save") { infoPurchaseMaster = SPPurchaseMaster.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId); } infoStockPosting.Date = infoPurchaseReturnMaster.Date; infoStockPosting.ProductId = infoPurchaseReturnDetails.ProductId; infoStockPosting.BatchId = infoPurchaseReturnDetails.BatchId; infoStockPosting.UnitId = infoPurchaseReturnDetails.UnitId; infoStockPosting.GodownId = infoPurchaseReturnDetails.GodownId; infoStockPosting.RackId = infoPurchaseReturnDetails.RackId; decimal decConversionId = SPUnitConversion.UnitConversionRateByUnitConversionId(infoPurchaseReturnDetails.UnitConversionId); //infoStockPosting.OutwardQty = infoPurchaseReturnDetails.Qty / (decConversionId == 0 ? 1 : decConversionId); infoStockPosting.OutwardQty = infoPurchaseReturnDetails.Qty; infoStockPosting.InwardQty = 0; infoStockPosting.Rate = infoPurchaseReturnDetails.Rate; infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; if (infoPurchaseReturnDetails.PurchaseDetailsId != 0) { infoStockPosting.AgainstVoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoStockPosting.AgainstVoucherNo = infoPurchaseMaster.VoucherNo; infoStockPosting.AgainstInvoiceNo = infoPurchaseMaster.InvoiceNo; infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.InvoiceNo = txtReturnNo.Text.Trim(); infoStockPosting.VoucherTypeId = decPurchaseReturnVoucherTypeId; decAgainstVoucherTypeId = infoStockPosting.VoucherTypeId; } else { infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.VoucherNo = infoPurchaseReturnMaster.VoucherNo; infoStockPosting.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoStockPosting.VoucherTypeId = decPurchaseReturnVoucherTypeId; decAgainstVoucherTypeId = 0; } spStockPosting.StockPostingAdd(infoStockPosting); } } if (btnSave.Text == "Update") { removePurchaseReturnDetails(); } infoAccountLedger = spAccountLedger.AccountLedgerView(infoPurchaseReturnMaster.LedgerId); if (infoAccountLedger.BillByBill == true) { infoPartyBalance.Date = infoPurchaseReturnMaster.Date; infoPartyBalance.LedgerId = infoPurchaseReturnMaster.LedgerId; if (decAgainstVoucherTypeId != 0) { infoPartyBalance.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoPartyBalance.VoucherNo = infoPurchaseMaster.VoucherNo; infoPartyBalance.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoPartyBalance.AgainstVoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId; infoPartyBalance.AgainstVoucherNo = infoPurchaseReturnMaster.VoucherNo; infoPartyBalance.AgainstInvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoPartyBalance.ReferenceType = "Against"; } else { infoPartyBalance.VoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId; infoPartyBalance.VoucherNo = infoPurchaseReturnMaster.VoucherNo; infoPartyBalance.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "NA"; infoPartyBalance.AgainstInvoiceNo = "NA"; infoPartyBalance.ReferenceType ="New"; } infoPartyBalance.Debit = infoPurchaseReturnMaster.TotalAmount; infoPartyBalance.Credit = 0; infoPartyBalance.CreditPeriod = 0; infoPartyBalance.ExchangeRateId = infoPurchaseReturnMaster.ExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; spPartyBalance.PartyBalanceAdd(infoPartyBalance); } foreach (DataGridViewRow item in dgvPurchaseReturnTax.Rows) { if (item.Cells["dgvtxtTaxId"].Value != null) { infoPurchaseReturnBillTax.PurchaseReturnMasterId = (btnSave.Text == "Save") ? decPurchaseReturnMasterIds : decPurchaseReturnMasterIds; infoPurchaseReturnBillTax.TaxId = Convert.ToDecimal(item.Cells["dgvtxtTaxId"].Value.ToString()); infoPurchaseReturnBillTax.TaxAmount = (item.Cells["dgvtxtAmounts"].Value == null) ? 0 : Convert.ToDecimal(item.Cells["dgvtxtAmounts"].Value.ToString()); infoPurchaseReturnBillTax.Extra1 = string.Empty; infoPurchaseReturnBillTax.Extra2 = string.Empty; spPurchaseReturnBillTax.PurchaseReturnBilltaxAdd(infoPurchaseReturnBillTax); } } if (btnSave.Text == "Save") { Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseReturnMasterIds); } else { Print(decPurchaseReturnMasterIds); } } Clear(); } else { decDiscount = Convert.ToDecimal(txtBillDiscount.Text); Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseReturnMasterId); } else { Print(decPurchaseReturnMasterId); } } if (frmPurchaseReturnRegisterObj != null) { frmPurchaseReturnRegisterObj.GridFill(); frmPurchaseReturnRegisterObj.Enabled = true; } if (ObjPurchaseReturnReport != null) { ObjPurchaseReturnReport.PurchaseReturnReportGridFill(); ObjPurchaseReturnReport.Enabled = true; } if (frmLedgerDetailsObj != null) { frmLedgerDetailsObj.LedgerDetailsView(); frmLedgerDetailsObj.Enabled = true; } this.Close(); } } catch (Exception ex) { MessageBox.Show("PR:49" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to insert values to PurchaseReturnMaster Table /// </summary> /// <param name="purchasereturnmasterinfo"></param> /// <returns></returns> public decimal PurchaseReturnMasterAddWithReturnIdentity(PurchaseReturnMasterInfo purchasereturnmasterinfo) { decimal decIdentity = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("PurchaseReturnMasterAddWithReturnIdentity", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.VoucherNo; sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.InvoiceNo; sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.SuffixPrefixId; sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.VoucherTypeId; sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam.Value = purchasereturnmasterinfo.Date; sprmparam = sccmd.Parameters.Add("@purchaseMasterId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.PurchaseMasterId; sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.LedgerId; sprmparam = sccmd.Parameters.Add("@discount", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.Discount; sprmparam = sccmd.Parameters.Add("@ExchangeRateId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.ExchangeRateId; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.Narration; sprmparam = sccmd.Parameters.Add("@purchaseAccount", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.PurchaseAccount; sprmparam = sccmd.Parameters.Add("@totalTax", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.TotalTax; sprmparam = sccmd.Parameters.Add("@grandTotal", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.GrandTotal; sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.TotalAmount; sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.UserId; sprmparam = sccmd.Parameters.Add("@lrNo", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.LrNo; sprmparam = sccmd.Parameters.Add("@transportationCompany", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.TransportationCompany; sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.FinancialYearId; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = purchasereturnmasterinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.Extra2; decIdentity = Convert.ToDecimal(sccmd.ExecuteScalar().ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(decIdentity); }
/// <summary> /// Function to insert values to PurchaseReturnMaster Table /// </summary> /// <param name="purchasereturnmasterinfo"></param> /// <returns></returns> public decimal PurchaseReturnMasterAddWithReturnIdentity(PurchaseReturnMasterInfo purchasereturnmasterinfo) { decimal decIdentity = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("PurchaseReturnMasterAddWithReturnIdentity", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.VoucherNo; sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.InvoiceNo; sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.SuffixPrefixId; sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.VoucherTypeId; sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam.Value = purchasereturnmasterinfo.Date; sprmparam = sccmd.Parameters.Add("@purchaseMasterId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.PurchaseMasterId; sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.LedgerId; sprmparam = sccmd.Parameters.Add("@discount", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.Discount; sprmparam = sccmd.Parameters.Add("@ExchangeRateId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.ExchangeRateId; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.Narration; sprmparam = sccmd.Parameters.Add("@purchaseAccount", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.PurchaseAccount; sprmparam = sccmd.Parameters.Add("@totalTax", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.TotalTax; sprmparam = sccmd.Parameters.Add("@grandTotal", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.GrandTotal; sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.TotalAmount; sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.UserId; sprmparam = sccmd.Parameters.Add("@lrNo", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.LrNo; sprmparam = sccmd.Parameters.Add("@transportationCompany", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.TransportationCompany; sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam.Value = purchasereturnmasterinfo.FinancialYearId; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = purchasereturnmasterinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = purchasereturnmasterinfo.Extra2; decIdentity = Convert.ToDecimal(sccmd.ExecuteScalar().ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return decIdentity; }
/// <summary> /// Function to get particular values from PurchaseReturnMaster table based on the parameter /// </summary> /// <param name="purchaseReturnMasterId"></param> /// <returns></returns> public PurchaseReturnMasterInfo PurchaseReturnMasterView(decimal purchaseReturnMasterId) { PurchaseReturnMasterInfo purchasereturnmasterinfo = new PurchaseReturnMasterInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("PurchaseReturnMasterView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@purchaseReturnMasterId", SqlDbType.Decimal); sprmparam.Value = purchaseReturnMasterId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { purchasereturnmasterinfo.PurchaseReturnMasterId = Convert.ToDecimal(sdrreader["purchaseReturnMasterId"].ToString()); purchasereturnmasterinfo.VoucherNo = sdrreader["voucherNo"].ToString(); purchasereturnmasterinfo.InvoiceNo = sdrreader["invoiceNo"].ToString(); purchasereturnmasterinfo.SuffixPrefixId = Convert.ToDecimal(sdrreader["suffixPrefixId"].ToString()); purchasereturnmasterinfo.VoucherTypeId = Convert.ToDecimal(sdrreader["voucherTypeId"].ToString()); purchasereturnmasterinfo.Date = Convert.ToDateTime(sdrreader["date"].ToString()); purchasereturnmasterinfo.LedgerId = Convert.ToDecimal(sdrreader["ledgerId"].ToString()); purchasereturnmasterinfo.Discount = Convert.ToDecimal(sdrreader["discount"].ToString()); purchasereturnmasterinfo.Narration = sdrreader["narration"].ToString(); purchasereturnmasterinfo.PurchaseAccount = Convert.ToDecimal(sdrreader["purchaseAccount"].ToString()); purchasereturnmasterinfo.TotalTax = Convert.ToDecimal(sdrreader["totalTax"].ToString()); purchasereturnmasterinfo.TotalAmount = Convert.ToDecimal(sdrreader["totalAmount"].ToString()); purchasereturnmasterinfo.GrandTotal = Convert.ToDecimal(sdrreader["grandTotal"].ToString()); purchasereturnmasterinfo.UserId = Convert.ToDecimal(sdrreader["userId"].ToString()); purchasereturnmasterinfo.LrNo = sdrreader["lrNo"].ToString(); purchasereturnmasterinfo.TransportationCompany = sdrreader["transportationCompany"].ToString(); purchasereturnmasterinfo.FinancialYearId = Convert.ToDecimal(sdrreader["financialYearId"].ToString()); purchasereturnmasterinfo.PurchaseMasterId = Convert.ToDecimal(sdrreader["purchaseMasterId"].ToString()); purchasereturnmasterinfo.ExchangeRateId = Convert.ToDecimal(sdrreader["exchangeRateId"].ToString()); purchasereturnmasterinfo.ExtraDate = Convert.ToDateTime(sdrreader["extraDate"].ToString()); purchasereturnmasterinfo.Extra1 = sdrreader["extra1"].ToString(); purchasereturnmasterinfo.Extra2 = sdrreader["extra2"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return purchasereturnmasterinfo; }