/// <summary> /// Edit function /// </summary> /// <param name="decMasterId"></param> public void Edit(decimal decMasterId) { try { int inRowCount = dgvReceiptVoucher.RowCount; int inTableRowCount = dtblPartyBalance.Rows.Count; int inB = 0; ReceiptMasterInfo InfoReceiptMaster = new ReceiptMasterInfo(); ReceiptDetailsInfo InfoReceiptDetails = new ReceiptDetailsInfo(); RecieptVoucherBll bllRecieptVoucher = new RecieptVoucherBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo InfoLegerPosting = new LedgerPostingInfo(); PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); BankReconciliationBll BllBankReconciliation = new BankReconciliationBll(); InfoReceiptMaster.Date = dtpDate.Value; InfoReceiptMaster.ReceiptMasterId = decMasterId; InfoReceiptMaster.Extra1 = string.Empty; InfoReceiptMaster.Extra2 = string.Empty; InfoReceiptMaster.ExtraDate = DateTime.Now; InfoReceiptMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoReceiptMaster.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString()); InfoReceiptMaster.Narration = txtNarration.Text.Trim(); decimal decTotalAmount = TotalAmountCalculation(); InfoReceiptMaster.TotalAmount = decTotalAmount; InfoReceiptMaster.UserId = PublicVariables._decCurrentUserId; if (!isAutomatic) { InfoReceiptMaster.VoucherNo = txtVoucherNo.Text.Trim(); InfoReceiptMaster.InvoiceNo = txtVoucherNo.Text.Trim(); InfoReceiptMaster.SuffixPrefixId = 0; } else { InfoReceiptMaster.VoucherNo = strVoucherNo; InfoReceiptMaster.InvoiceNo = strInvoiceNo; InfoReceiptMaster.SuffixPrefixId = decDailySuffixPrefixId; } InfoReceiptMaster.VoucherTypeId = decReceiptVoucherTypeId; decimal decEffectRow = bllRecieptVoucher.ReceiptMasterEdit(InfoReceiptMaster); if (decEffectRow != 0) { MasterLedgerPostingEdit(); } foreach (object obj in arrlstOfRemove) { string str = Convert.ToString(obj); bllRecieptVoucher.ReceiptDetailsDelete(Convert.ToDecimal(str)); BllLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(str), strVoucherNo, decReceiptVoucherTypeId); } decimal decReceiptDetailsId1 = 0; BllLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decReceiptVoucherTypeId, 12); for (int inI = 0; inI < inRowCount - 1; inI++) { InfoReceiptDetails.Amount = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); InfoReceiptDetails.ExchangeRateId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()); InfoReceiptDetails.Extra1 = string.Empty; InfoReceiptDetails.Extra2 = string.Empty; InfoReceiptDetails.ReceiptMasterId = InfoReceiptMaster.ReceiptMasterId; if (dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { InfoReceiptDetails.LedgerId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); } if (dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { InfoReceiptDetails.ChequeNo = dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString(); if (dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty) { InfoReceiptDetails.ChequeDate = Convert.ToDateTime(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value); } else { InfoReceiptDetails.ChequeDate = DateTime.Now; } } else { InfoReceiptDetails.ChequeNo = string.Empty; InfoReceiptDetails.ChequeDate = DateTime.Now; } if (dgvReceiptVoucher.Rows[inI].Cells["dgvtxtReceiptDetailsId"].Value == null || dgvReceiptVoucher.Rows[inI].Cells["dgvtxtReceiptDetailsId"].Value.ToString() == string.Empty)//if new rows are added { if (dgvReceiptVoucher.Rows[inI].HeaderCell.Value.ToString() != "X") { decimal decReceiptDetailsId = bllRecieptVoucher .ReceiptDetailsAdd(InfoReceiptDetails); if (decReceiptDetailsId != 0) { for (int inJ = 0; inJ < inTableRowCount; inJ++) { if (dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString()) { PartyBalanceAddOrEdit(inJ); } } inB++; DetailsLedgerPosting(inI, decReceiptDetailsId); } } } else { if (dgvReceiptVoucher.Rows[inI].HeaderCell.Value.ToString() != "X") { InfoReceiptDetails.ReceiptDetailsId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtreceiptDetailsId"].Value.ToString()); decimal decReceiptDetailsId = bllRecieptVoucher.ReceiptDetailsEdit(InfoReceiptDetails); if (decReceiptDetailsId != 0) { for (int inJ = 0; inJ < inTableRowCount; inJ++) { if (dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString()) { PartyBalanceAddOrEdit(inJ); } } inB++; decReceiptDetailsId = InfoReceiptDetails.ReceiptDetailsId; decimal decLedgerPostId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value.ToString()); DetailsLedgerPostingEdit(inI, decLedgerPostId, decReceiptDetailsId1); } } else { decimal decDetailsId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtreceiptDetailsId"].Value.ToString()); bllRecieptVoucher.ReceiptDetailsDelete(decDetailsId); BllLedgerPosting.LedgerPostDeleteByDetailsId(decDetailsId, strVoucherNo, decReceiptVoucherTypeId); for (int inJ = 0; inJ < dtblPartyBalance.Rows.Count; inJ++) { if (dtblPartyBalance.Rows.Count == inJ) { break; } if (dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { if (dtblPartyBalance.Rows[inJ]["LedgerId"].ToString() == dgvReceiptVoucher.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 (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(InfoReceiptMaster.ReceiptMasterId); } else { Print(InfoReceiptMaster.ReceiptMasterId); } } if (frmReceiptRegisterObj != null) { this.Close(); frmReceiptRegisterObj.CallFromReceiptVoucher(this); } if (frmReceiptReportObj != null) { this.Close(); frmReceiptReportObj.CallFromReceiptVoucher(this); } if (frmDayBookObj != null) { this.Close(); } if (frmBillallocationObj != null) { this.Close(); } } catch (Exception ex) { MessageBox.Show("RV13:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save function /// </summary> public void Save() { try { int inGridRowCount = dgvReceiptVoucher.RowCount; int inTableRowCount = dtblPartyBalance.Rows.Count; int inB = 0; ReceiptMasterInfo InfoReceiptMaster = new ReceiptMasterInfo(); RecieptVoucherBll bllRecieptVoucher=new RecieptVoucherBll(); // ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); ReceiptDetailsInfo InfoReceiptDetails = new ReceiptDetailsInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); InfoReceiptMaster.Date = dtpDate.Value; InfoReceiptMaster.Extra1 = string.Empty; InfoReceiptMaster.Extra2 = string.Empty; InfoReceiptMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoReceiptMaster.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString()); InfoReceiptMaster.Narration = txtNarration.Text; decimal decTotalAmount = TotalAmountCalculation(); InfoReceiptMaster.TotalAmount = decTotalAmount; InfoReceiptMaster.UserId = PublicVariables._decCurrentUserId; if (!isAutomatic) { InfoReceiptMaster.VoucherNo = txtVoucherNo.Text.Trim(); InfoReceiptMaster.InvoiceNo = txtVoucherNo.Text.Trim(); InfoReceiptMaster.SuffixPrefixId = 0; } else { InfoReceiptMaster.VoucherNo = strVoucherNo; InfoReceiptMaster.InvoiceNo = strInvoiceNo; InfoReceiptMaster.SuffixPrefixId = decDailySuffixPrefixId; } InfoReceiptMaster.VoucherTypeId = decReceiptVoucherTypeId; decimal decReceiptMasterId = bllRecieptVoucher.ReceiptMasterAdd(InfoReceiptMaster); if (decReceiptMasterId != 0) { MasterLedgerPosting(); } for (int inI = 0; inI < inGridRowCount - 1; inI++) { if (dgvReceiptVoucher.Rows[inI].HeaderCell.Value.ToString() != "X") { InfoReceiptDetails.Amount = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); InfoReceiptDetails.ExchangeRateId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()); InfoReceiptDetails.Extra1 = string.Empty; InfoReceiptDetails.Extra2 = string.Empty; InfoReceiptDetails.LedgerId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); InfoReceiptDetails.ReceiptMasterId = decReceiptMasterId; if (dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { InfoReceiptDetails.LedgerId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); } if (dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { InfoReceiptDetails.ChequeNo = dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString(); if (dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty) { InfoReceiptDetails.ChequeDate = Convert.ToDateTime(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value); } else { InfoReceiptDetails.ChequeDate = DateTime.Now; } } else { InfoReceiptDetails.ChequeNo = string.Empty; InfoReceiptDetails.ChequeDate = DateTime.Now; } decimal decReceiptDetailsId = bllRecieptVoucher.ReceiptDetailsAdd(InfoReceiptDetails); if (decReceiptDetailsId != 0) { for (int inJ = 0; inJ < inTableRowCount; inJ++) { if (dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString()) { PartyBalanceAddOrEdit(inJ); } } inB++; DetailsLedgerPosting(inI, decReceiptDetailsId); } } } Messages.SavedMessage(); if (cbxPrintafterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decReceiptMasterId); } else { Print(decReceiptMasterId); } } Clear(); } catch (Exception ex) { MessageBox.Show("RV12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }