/// <summary> /// Save function /// </summary> public void Save() { try { int inGridRowCount = dgvReceiptVoucher.RowCount; int inTableRowCount = dtblPartyBalance.Rows.Count; int inB = 0; ReceiptMasterInfo InfoReceiptMaster = new ReceiptMasterInfo(); ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); ReceiptDetailsInfo InfoReceiptDetails = new ReceiptDetailsInfo(); ReceiptDetailsSP SpReceiptDetails = new ReceiptDetailsSP(); PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); 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 = SpReceiptMaster.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 = SpReceiptDetails.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 (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decReceiptMasterId); } else { Print(decReceiptMasterId); } } Clear(); } catch (Exception ex) { MessageBox.Show("RV12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <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(); ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); ReceiptDetailsInfo InfoReceiptDetails = new ReceiptDetailsInfo(); ReceiptDetailsSP SpReceiptDetails = new ReceiptDetailsSP(); LedgerPostingSP SpLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo InfoLegerPosting = new LedgerPostingInfo(); PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); BankReconciliationSP SpBankReconcilation = new BankReconciliationSP(); 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 = SpReceiptMaster.ReceiptMasterEdit(InfoReceiptMaster); if (decEffectRow != 0) { MasterLedgerPostingEdit(); } foreach (object obj in arrlstOfRemove) { string str = Convert.ToString(obj); SpReceiptDetails.ReceiptDetailsDelete(Convert.ToDecimal(str)); SpLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(str), strVoucherNo, decReceiptVoucherTypeId); } decimal decReceiptDetailsId1 = 0; SpLedgerPosting.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 = SpReceiptDetails.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 = SpReceiptDetails.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()); SpReceiptDetails.ReceiptDetailsDelete(decDetailsId); SpLedgerPosting.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 (spSettings.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> /// Fill function for updation /// </summary> public void FillFunction() { try { isValueChange = false; ReceiptMasterInfo InfoReceiptMaster = new ReceiptMasterInfo(); ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); ReceiptDetailsInfo InfoReceiptDetails = new ReceiptDetailsInfo(); ReceiptDetailsSP SpReceiptDetails = new ReceiptDetailsSP(); PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); LedgerPostingSP SpLedgerPosting = new LedgerPostingSP(); VoucherTypeSP SpVoucherType = new VoucherTypeSP(); AccountGroupSP spAccountGroup = new AccountGroupSP(); AccountLedgerSP SpAccountLedger = new AccountLedgerSP(); InfoReceiptMaster = SpReceiptMaster.ReceiptMasterViewByMasterId(decRecieptmasterId); isAutomatic = SpVoucherType.CheckMethodOfVoucherNumbering(InfoReceiptMaster.VoucherTypeId); if (isAutomatic) { txtVoucherNo.ReadOnly = true; txtVoucherNo.Text = InfoReceiptMaster.InvoiceNo; } else { txtVoucherNo.ReadOnly = false; txtVoucherNo.Text = InfoReceiptMaster.VoucherNo; } dtpDate.Value = InfoReceiptMaster.Date; cmbCashOrBank.SelectedValue = InfoReceiptMaster.LedgerId; txtNarration.Text = InfoReceiptMaster.Narration; txtTotal.Text = InfoReceiptMaster.TotalAmount.ToString(); decDailySuffixPrefixId = InfoReceiptMaster.SuffixPrefixId; decReceiptVoucherTypeId = InfoReceiptMaster.VoucherTypeId; strVoucherNo = InfoReceiptMaster.VoucherNo; strInvoiceNo = InfoReceiptMaster.InvoiceNo; DataTable dtbl = new DataTable(); dtbl = SpReceiptDetails.ReceiptDetailsViewByMasterId(decRecieptmasterId); for (int inI = 0; inI < dtbl.Rows.Count; inI++) { dgvReceiptVoucher.Rows.Add(); dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(dtbl.Rows[inI]["ledgerId"].ToString()); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtreceiptMasterId"].Value = dtbl.Rows[inI]["receiptMasterId"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtreceiptDetailsId"].Value = dtbl.Rows[inI]["receiptDetailsId"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].Value = dtbl.Rows[inI]["amount"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(dtbl.Rows[inI]["exchangeRateId"].ToString()); decimal decDetailsId1 = Convert.ToDecimal(dtbl.Rows[inI]["receiptDetailsId"].ToString()); decimal decLedgerPostingId = SpLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decReceiptVoucherTypeId); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString(); decimal decLedgerId = Convert.ToDecimal(dtbl.Rows[inI]["ledgerId"].ToString()); bool IsBankAccount = spAccountGroup.AccountGroupwithLedgerId(decLedgerId); decimal decI = Convert.ToDecimal(SpAccountLedger.AccountGroupIdCheck(dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].FormattedValue.ToString())); if (decI > 0) { dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = true; dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = true; } else { dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = false; dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = false; } if (dtbl.Rows[inI]["chequeNo"].ToString() != string.Empty) { dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value = dtbl.Rows[inI]["chequeNo"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value = Convert.ToDateTime(dtbl.Rows[inI]["chequeDate"].ToString()).ToString("dd-MMM-yyyy"); } dgvReceiptVoucher.Rows[inI].HeaderCell.Value = string.Empty; } DataTable dtbl1 = new DataTable(); dtbl1 = SpPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decReceiptVoucherTypeId, strVoucherNo, InfoReceiptMaster.Date); dtblPartyBalance = dtbl1; isValueChange = true; } catch (Exception ex) { MessageBox.Show("RV34:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }