/// <summary> /// Function to edit the debitnote voucher /// </summary> /// <param name="decJournalMasterId"></param> public void Edit(decimal decJournalMasterId) { try { JournalMasterSP spJournalMaster = new JournalMasterSP(); JournalMasterInfo infoJournalMaster = new JournalMasterInfo(); JournalDetailsSP spJournalDetails = new JournalDetailsSP(); JournalDetailsInfo infoJournalDetails = new JournalDetailsInfo(); ExchangeRateSP spExchangeRate = new ExchangeRateSP(); /*****************Update in JournalMaster table *************/ decimal decTotalDebit = 0; decimal decTotalCredit = 0; infoJournalMaster.JournalMasterId = decJournalMasterId; infoJournalMaster.VoucherNo = strVoucherNo; infoJournalMaster.InvoiceNo = txtVoucherNo.Text.Trim(); infoJournalMaster.SuffixPrefixId = decJournalSuffixPrefixId; infoJournalMaster.Date = Convert.ToDateTime(txtDate.Text); infoJournalMaster.Narration = txtNarration.Text.Trim(); infoJournalMaster.UserId = PublicVariables._decCurrentUserId; infoJournalMaster.VoucherTypeId = decJournalVoucherTypeId; infoJournalMaster.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString()); infoJournalMaster.ExtraDate = DateTime.Now; infoJournalMaster.Extra1 = string.Empty; infoJournalMaster.Extra2 = string.Empty; decTotalDebit = Convert.ToDecimal(txtDebitTotal.Text.Trim()); decTotalCredit = Convert.ToDecimal(txtCreditTotal.Text.Trim()); infoJournalMaster.TotalAmount = decTotalDebit; decimal decEffectRow = spJournalMaster.JournalMasterEdit(infoJournalMaster); /**********************JournalDetails Edit********************/ if (decEffectRow > 0) { infoJournalDetails.JournalMasterId = decJournalMasterId; infoJournalDetails.ExtraDate = DateTime.Now; infoJournalDetails.Extra1 = string.Empty; infoJournalDetails.Extra2 = string.Empty; //-----------to delete details, LedgerPosting and bankReconciliation of removed rows--------------// LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); foreach (object obj in arrlstOfRemove) { string str = Convert.ToString(obj); spJournalDetails.JournalDetailsDelete(Convert.ToDecimal(str)); spLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(str), strVoucherNo, decJournalVoucherTypeId); } spLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decJournalVoucherTypeId, 12); //=============================================================================================// decimal decLedgerId = 0; decimal decDebit = 0; decimal decCredit = 0; decimal decJournalDetailsId = 0; int inRowCount = dgvJournalVoucher.RowCount; for (int inI = 0; inI < inRowCount; inI++) { if (dgvJournalVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { infoJournalDetails.LedgerId = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); decLedgerId = infoJournalDetails.LedgerId; } if (dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() != string.Empty) { //------------------Currency conversion------------------// decSelectedCurrencyRate = spExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value)); decAmount = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); decConvertRate = decAmount * decSelectedCurrencyRate; //======================================================// if (dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() == "Dr") { infoJournalDetails.Debit = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoJournalDetails.Credit = 0; decDebit = decConvertRate; decCredit = infoJournalDetails.Credit; } else { infoJournalDetails.Credit = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoJournalDetails.Debit = 0; decDebit = infoJournalDetails.Debit; decCredit = decConvertRate; } infoJournalDetails.ExchangeRateId = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()); if (dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { infoJournalDetails.ChequeNo = dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString(); } else { infoJournalDetails.ChequeNo = string.Empty; } if (dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty) { infoJournalDetails.ChequeDate = Convert.ToDateTime(dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString()); } else { infoJournalDetails.ChequeDate = DateTime.Now; } if (dgvJournalVoucher.Rows[inI].Cells["dgvtxtDetailsId"].Value != null && dgvJournalVoucher.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString() != string.Empty) { infoJournalDetails.JournalDetailsId = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString()); spJournalDetails.JournalDetailsEdit(infoJournalDetails); PartyBalanceAddOrEdit(inI); decJournalDetailsId = infoJournalDetails.JournalDetailsId; decimal decLedgerPostId = Convert.ToDecimal(dgvJournalVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value.ToString()); LedgerPostingEdit(decLedgerPostId, decLedgerId, decCredit, decDebit, decJournalDetailsId, inI); } else { decJournalDetailsId = spJournalDetails.JournalDetailsAdd(infoJournalDetails); PartyBalanceAddOrEdit(inI); LedgerPosting(decLedgerId, decCredit, decDebit, decJournalDetailsId, inI); } } } DeletePartyBalanceOfRemovedRow(); Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(infoJournalMaster.JournalMasterId); } else { Print(infoJournalMaster.JournalMasterId); } } if (journalRegisterObj != null) { this.Close(); journalRegisterObj.Enabled = true; } else if (frmJournalReportObj != null) { this.Close(); frmJournalReportObj.Enabled = true; } else if (frmDayBookObj != null) { this.Close(); } else if (frmBillallocationObj != null) { this.Close(); } } //----------------If print after save is enable-----------------------// //===================================================================// } catch (Exception ex) { MessageBox.Show("JV16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Edit Function /// </summary> /// <param name="decMasterId"></param> public void Edit(decimal decMasterId) { try { int inRowCount = dgvPaymentVoucher.RowCount; int inTableRowCount = dtblPartyBalance.Rows.Count; int inB = 0; PaymentMasterInfo InfoPaymentMaster = new PaymentMasterInfo(); PaymentMasterSP SpPaymentMaster = new PaymentMasterSP(); PaymentDetailsInfo InfoPaymentDetails = new PaymentDetailsInfo(); PaymentDetailsSP SpPaymentDetails = new PaymentDetailsSP(); LedgerPostingSP SpLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo InfoLegerPosting = new LedgerPostingInfo(); PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); BankReconciliationSP SpBankReconcilation = new BankReconciliationSP(); InfoPaymentMaster.Date = dtpDate.Value; InfoPaymentMaster.PaymentMasterId = decMasterId; InfoPaymentMaster.Extra1 = string.Empty; InfoPaymentMaster.Extra2 = string.Empty; InfoPaymentMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoPaymentMaster.InvoiceNo = txtVoucherNo.Text.Trim(); InfoPaymentMaster.LedgerId = Convert.ToDecimal(cmbBankorCash.SelectedValue.ToString()); InfoPaymentMaster.Narration = txtNarration.Text.Trim(); InfoPaymentMaster.SuffixPrefixId = decDailySuffixPrefixId; decimal decTotalAmount = TotalAmountCalculation(); InfoPaymentMaster.TotalAmount = decTotalAmount; InfoPaymentMaster.UserId = PublicVariables._decCurrentUserId; InfoPaymentMaster.VoucherNo = strVoucherNo; InfoPaymentMaster.VoucherTypeId = decPaymentVoucherTypeId; decimal decPaymentMasterId = SpPaymentMaster.PaymentMasterEdit(InfoPaymentMaster); if (decPaymentmasterId != 0) { MasterLedgerPostingEdit(); } foreach (object obj in arrlstOfRemove) { string str = Convert.ToString(obj); SpPaymentDetails.PaymentDetailsDelete(Convert.ToDecimal(str)); SpLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(str), strVoucherNo, decPaymentVoucherTypeId); } SpLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decPaymentVoucherTypeId, 12); decimal decPaymentDetailsId1 = 0; for (int inI = 0; inI < inRowCount - 1; inI++) { InfoPaymentDetails.Amount = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); InfoPaymentDetails.ExchangeRateId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()); InfoPaymentDetails.Extra1 = string.Empty; InfoPaymentDetails.Extra2 = string.Empty; if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { InfoPaymentDetails.LedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); } if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { InfoPaymentDetails.ChequeNo = dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString(); if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty) { InfoPaymentDetails.ChequeDate = Convert.ToDateTime(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value); } else { InfoPaymentDetails.ChequeDate = DateTime.Now; } } else { InfoPaymentDetails.ChequeNo = string.Empty; InfoPaymentDetails.ChequeDate = DateTime.Now; } InfoPaymentDetails.PaymentMasterId = decPaymentMasterId; if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].FormattedValue.ToString() == "0")//if new rows are added { if (dgvPaymentVoucher.Rows[inI].HeaderCell.Value.ToString() != "X")//add new rows added which are completed { decimal decPaymentDetailsId = SpPaymentDetails.PaymentDetailsAdd(InfoPaymentDetails);//to add new rows in payment details if (decPaymentDetailsId != 0) { for (int inJ = 0; inJ < inTableRowCount; inJ++) { if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString()) { PartyBalanceAddOrEdit(inJ); } } inB++; DetailsLedgerPosting(inI, decPaymentDetailsId);//to add new ledger posting } } } else { if (dgvPaymentVoucher.Rows[inI].HeaderCell.Value.ToString() != "X")//add new rows updated which are completed { InfoPaymentDetails.PaymentDetailsId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].Value.ToString()); decimal decPaymentDetailsId = SpPaymentDetails.PaymentDetailsEdit(InfoPaymentDetails);//to edit rows if (decPaymentDetailsId != 0) { for (int inJ = 0; inJ < inTableRowCount; inJ++) { if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString()) { PartyBalanceAddOrEdit(inJ); } } inB++; decPaymentDetailsId1 = InfoPaymentDetails.PaymentDetailsId; decimal decLedgerPostId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value.ToString()); DetailsLedgerPostingEdit(inI, decLedgerPostId, decPaymentDetailsId1); } } else { decimal decDetailsId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].Value.ToString()); SpPaymentDetails.PaymentDetailsDelete(decDetailsId); SpLedgerPosting.LedgerPostDeleteByDetailsId(decDetailsId, strVoucherNo, decPaymentVoucherTypeId); for (int inJ = 0; inJ < dtblPartyBalance.Rows.Count; inJ++) { if (dtblPartyBalance.Rows.Count == inJ) { break; } if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { if (dtblPartyBalance.Rows[inJ]["LedgerId"].ToString() == dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()) { if (dtblPartyBalance.Rows[inJ]["PartyBalanceId"].ToString() != "0") { arrlstOfDeletedPartyBalanceRow.Add(dtblPartyBalance.Rows[inJ]["PartyBalanceId"]); } } } } } } } DeletePartyBalanceOfRemovedRow(); isUpdated = true; Messages.UpdatedMessage(); if (cbxPrintafterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPaymentmasterId); } else { Print(decPaymentMasterId); } } if (frmPaymentRegisterObj != null) { this.Close(); frmPaymentRegisterObj.CallFromPaymentVoucher(this); } if (frmPaymentReportObj != null) { this.Close(); frmPaymentReportObj.CallFromPaymentVoucher(this); } if (frmDayBookObj != null) { this.Close(); } if (frmBillallocationObj != null) { this.Close(); } this.Close(); } catch (Exception ex) { MessageBox.Show("PV18:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save function /// </summary> public void SaveFunction() { try { DateValidation Objdatevalidation = new DateValidation(); OtherDateValidationFunction ObjotherdateValidation = new OtherDateValidationFunction(); Objdatevalidation.DateValidationFunction(txtVoucherDate); ObjotherdateValidation.DateValidationFunction(txtCheckDate, false); DataTable dtblMaster = new DataTable(); PDCReceivableMasterSP spPdcReceivable = new PDCReceivableMasterSP(); PDCReceivableMasterInfo InfopdcRecivable = new PDCReceivableMasterInfo(); PartyBalanceSP spPartyBalance = new PartyBalanceSP(); InfopdcRecivable.VoucherNo = strVoucherNo; InfopdcRecivable.InvoiceNo = txtVoucherNo.Text.Trim(); InfopdcRecivable.Date = DateTime.Parse(txtVoucherDate.Text); InfopdcRecivable.LedgerId = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString()); InfopdcRecivable.Amount = decimal.Parse(txtAmount.Text); InfopdcRecivable.Narration = txtNarration.Text; if (txtcheckNo.Text != string.Empty) InfopdcRecivable.ChequeNo = txtcheckNo.Text; else InfopdcRecivable.ChequeNo = string.Empty; if (txtCheckDate.Text != string.Empty) InfopdcRecivable.ChequeDate = Convert.ToDateTime(txtCheckDate.Text); else InfopdcRecivable.ChequeDate = DateTime.Now; InfopdcRecivable.UserId = PublicVariables._decCurrentUserId; InfopdcRecivable.VoucherTypeId = decPDCReceivableVoucherTypeId; if (cmbBank.SelectedValue != null && cmbBank.SelectedValue.ToString() != string.Empty) { InfopdcRecivable.BankId = Convert.ToDecimal(cmbBank.SelectedValue.ToString()); } else InfopdcRecivable.BankId = 0; InfopdcRecivable.ExtraDate = DateTime.Now; InfopdcRecivable.Extra1 = string.Empty; InfopdcRecivable.Extra2 = string.Empty; if (!isInEditMode) { decimal decIdentity = spPdcReceivable.PDCReceivableMasterAdd(InfopdcRecivable); LedgerPosting(); PartyBalanceAddOrEdit(); Messages.SavedMessage(); if (cbxPrint.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decIdentity); } else { Print(decIdentity); } } ClearFunction(); } else { decimal decIdentity = decPDCReceivableEditId; InfopdcRecivable.PdcReceivableMasterId = decPDCReceivableEditId; spPdcReceivable.PDCReceivableMasterEdit(InfopdcRecivable); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); spLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decPDCReceivableVoucherTypeId, 12); spPartyBalance.PartyBalanceDeleteByVoucherTypeAndVoucherNo(decPDCReceivableVoucherTypeId, strVoucherNo); PartyBalanceAddOrEdit(); LedgerPostingEdit(decPDCReceivableEditId); Messages.UpdatedMessage(); if (cbxPrint.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decIdentity); } else { Print(decIdentity); } } this.Close(); } } catch (Exception ex) { MessageBox.Show("PR9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }