/// <summary> /// /// </summary> /// <param name="infoAccountLedger"></param> /// <returns></returns> public decimal AccountLedgerAddWithIdentity(AccountLedgerInfo infoAccountLedger) { decimal decLedgerId = 0; try { decLedgerId = spAccountLedger.AccountLedgerAddWithIdentity(infoAccountLedger); } catch (Exception ex) { MessageBox.Show("AL2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(decLedgerId); }
/// <summary> /// Save data to the database /// </summary> public void SaveFunction() { try { int inRowcount = dgvMultipleAccountLedger.RowCount;//edited by Runali int inRowcountDec = (dgvMultipleAccountLedger.RowCount) - 1; decimal decOpeningBalance = 0; decimal decLedgerId = 0; bool isSave = false; AccountLedgerInfo infoAccountledger = new AccountLedgerInfo(); AccountLedgerSP spAccountledger = new AccountLedgerSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); FinancialYearSP spFinancialYear = new FinancialYearSP(); FinancialYearInfo infoFinancialYear = new FinancialYearInfo(); for (int i = 0; i < inRowcount - 1; i++) { infoAccountledger.AccountGroupId = Convert.ToDecimal(cmbAccountGroup.SelectedValue.ToString()); infoAccountledger.LedgerName = dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtLedgerName"].Value.ToString(); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value != null) { infoAccountledger.OpeningBalance = Convert.ToDecimal(dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString()); } else { infoAccountledger.OpeningBalance = 0; } infoAccountledger.CrOrDr = dgvMultipleAccountLedger.Rows[i].Cells["dgvcmbDebitOrCredit"].Value.ToString(); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtNarration"].Value != null) { infoAccountledger.Narration = dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtNarration"].Value.ToString(); } else { infoAccountledger.Narration = string.Empty; } infoAccountledger.MailingName = string.Empty; infoAccountledger.Address = string.Empty; infoAccountledger.State = string.Empty; infoAccountledger.Phone = string.Empty; infoAccountledger.Mobile = string.Empty; infoAccountledger.Email = string.Empty; infoAccountledger.CreditPeriod = 0; infoAccountledger.CreditLimit = 0; infoAccountledger.PricinglevelId = 0; infoAccountledger.BillByBill = false; infoAccountledger.Tin = string.Empty; infoAccountledger.Cst = string.Empty; infoAccountledger.Pan = string.Empty; infoAccountledger.RouteId = 0; infoAccountledger.BankAccountNumber = string.Empty; infoAccountledger.BranchName = string.Empty; infoAccountledger.BranchCode = string.Empty; infoAccountledger.Extra1 = string.Empty; infoAccountledger.Extra2 = string.Empty; infoAccountledger.AreaId = 0; infoAccountledger.IsDefault = false; decLedgerId = spAccountledger.AccountLedgerAddWithIdentity(infoAccountledger); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value != null && dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString() != "0") { if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString() != string.Empty) { string strfinancialId; decOpeningBalance = Convert.ToDecimal(dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString()); infoFinancialYear = spFinancialYear.FinancialYearViewForAccountLedger(1); strfinancialId = infoFinancialYear.FromDate.ToString("dd-MMM-yyyy"); infoLedgerPosting.VoucherTypeId = 1; infoLedgerPosting.Date = Convert.ToDateTime(strfinancialId.ToString()); infoLedgerPosting.LedgerId = decLedgerId; infoLedgerPosting.VoucherNo = decLedgerId.ToString(); if (dgvMultipleAccountLedger.Rows[i].Cells["dgvcmbDebitOrCredit"].Value.ToString() == "Dr") { infoLedgerPosting.Debit = decOpeningBalance; } else { infoLedgerPosting.Credit = decOpeningBalance; } infoLedgerPosting.DetailsId = 0; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.InvoiceNo = decLedgerId.ToString(); infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } isSave = true; } if (isSave) { Messages.SavedMessage(); cmbAccountGroup.Focus(); cmbAccountGroup.SelectedIndex = -1; dgvMultipleAccountLedger.Rows.Clear(); } else { } } catch (Exception ex) { MessageBox.Show("MAL6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }