/// <summary> /// Function to update ledger posting table /// </summary> public void LedgerUpdate() { try { decimal decLedgerPostingId = 0; LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); DataTable dtbl = new DataTable(); dtbl = spLedgerPosting.GetLedgerPostingIds(strVoucherNo, decMonthlyVoucherTypeId); int ini = 0; foreach (DataRow dr in dtbl.Rows) { ini++; if (ini == 2) { decLedgerPostingId = Convert.ToDecimal(dr.ItemArray[0].ToString()); infoLedgerPosting.LedgerPostingId = decLedgerPostingId; infoLedgerPosting.Date = Convert.ToDateTime(dtpVoucherDate.Value.ToString()); if (isAutomatic) { infoLedgerPosting.VoucherNo = strVoucherNo; } else { infoLedgerPosting.VoucherNo = txtVoucherNo.Text; } infoLedgerPosting.Debit = Convert.ToDecimal(lblTotalAmount.Text.ToString()); infoLedgerPosting.Credit = 0; infoLedgerPosting.VoucherTypeId = decMonthlyVoucherTypeId; infoLedgerPosting.LedgerId = 4; infoLedgerPosting.DetailsId = 0; if (isAutomatic) { infoLedgerPosting.InvoiceNo = strInvoiceNo; } else { infoLedgerPosting.InvoiceNo = txtVoucherNo.Text; } infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingEdit(infoLedgerPosting); } if (ini == 1) { decLedgerPostingId = Convert.ToDecimal(dr.ItemArray[0].ToString()); infoLedgerPosting.LedgerPostingId = decLedgerPostingId; infoLedgerPosting.Date = PublicVariables._dtCurrentDate; if (isAutomatic) { infoLedgerPosting.VoucherNo = strVoucherNo; } else { infoLedgerPosting.VoucherNo = txtVoucherNo.Text; } infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = Convert.ToDecimal(lblTotalAmount.Text.ToString()); infoLedgerPosting.VoucherTypeId = decMonthlyVoucherTypeId; infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbCashOrBankAcc.SelectedValue.ToString()); infoLedgerPosting.DetailsId = 0; if (isAutomatic) { infoLedgerPosting.InvoiceNo = strInvoiceNo; } else { infoLedgerPosting.InvoiceNo = txtVoucherNo.Text; } infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; spLedgerPosting.LedgerPostingEdit(infoLedgerPosting); } } } catch (Exception ex) { MessageBox.Show("MSV5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to update values in ledgerposting table /// </summary> public void ledgerUpdate() { try { string strfinancialId; FinancialYearSP spFinancialYear = new FinancialYearSP(); FinancialYearInfo infoFinancialYear = new FinancialYearInfo(); infoFinancialYear = spFinancialYear.FinancialYearViewForAccountLedger(1); strfinancialId = infoFinancialYear.FromDate.ToString("dd-MMM-yyyy"); decimal decLedgerPostingId = 0; if (txtOpeningBalance.Text.Trim() != string.Empty) { decOpeningBlnc = Convert.ToDecimal(txtOpeningBalance.Text.Trim()); } else { decOpeningBlnc = 0; } LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); DataTable dtbl = spLedgerPosting.GetLedgerPostingIds(decLedgerIdForEdit.ToString(), 1); foreach (DataRow dr in dtbl.Rows) { decLedgerPostingId = Convert.ToDecimal(dr.ItemArray[0].ToString()); } if (cmbDrorCr.Text == "Dr") { infoLedgerPosting.Debit = decOpeningBlnc; } else { infoLedgerPosting.Credit = decOpeningBlnc; } infoLedgerPosting.LedgerPostingId = decLedgerPostingId; infoLedgerPosting.VoucherTypeId = 1; infoLedgerPosting.VoucherNo = decLedgerIdForEdit.ToString(); infoLedgerPosting.Date = Convert.ToDateTime(strfinancialId.ToString()); infoLedgerPosting.LedgerId = decLedgerIdForEdit; infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = decLedgerIdForEdit.ToString(); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; if (dtbl.Rows.Count > 0) { if (decOpeningBlnc > 0) { spLedgerPosting.LedgerPostingEdit(infoLedgerPosting); } else { AccountLedgerSP spAccountLedger = new AccountLedgerSP(); spAccountLedger.LedgerPostingDeleteByVoucherTypeAndVoucherNo(decLedgerIdForEdit.ToString(), 1); } } else { spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } catch (Exception ex) { MessageBox.Show("Cus16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }