/// <summary> /// Function to Update values in LedgerPosting Table /// </summary> /// <param name="ledgerpostinginfo"></param> public void LedgerPostingEdit(LedgerPostingInfo ledgerpostinginfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("LedgerPostingEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@ledgerPostingId", SqlDbType.Decimal); sprmparam.Value = ledgerpostinginfo.LedgerPostingId; sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam.Value = ledgerpostinginfo.Date; sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam.Value = ledgerpostinginfo.VoucherTypeId; sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam.Value = ledgerpostinginfo.VoucherNo; sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam.Value = ledgerpostinginfo.LedgerId; sprmparam = sccmd.Parameters.Add("@debit", SqlDbType.Decimal); sprmparam.Value = ledgerpostinginfo.Debit; sprmparam = sccmd.Parameters.Add("@credit", SqlDbType.Decimal); sprmparam.Value = ledgerpostinginfo.Credit; sprmparam = sccmd.Parameters.Add("@detailsId", SqlDbType.Decimal); sprmparam.Value = ledgerpostinginfo.DetailsId; sprmparam = sccmd.Parameters.Add("@yearId", SqlDbType.Decimal); sprmparam.Value = ledgerpostinginfo.YearId; sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam.Value = ledgerpostinginfo.InvoiceNo; sprmparam = sccmd.Parameters.Add("@chequeNo", SqlDbType.VarChar); sprmparam.Value = ledgerpostinginfo.ChequeNo; sprmparam = sccmd.Parameters.Add("@chequeDate", SqlDbType.DateTime); sprmparam.Value = ledgerpostinginfo.ChequeDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = ledgerpostinginfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = ledgerpostinginfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Function to get particular values from LedgerPosting table based on the parameter /// </summary> /// <param name="ledgerPostingId"></param> /// <returns></returns> public LedgerPostingInfo LedgerPostingView(decimal ledgerPostingId) { LedgerPostingInfo ledgerpostinginfo = new LedgerPostingInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("LedgerPostingView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@ledgerPostingId", SqlDbType.Decimal); sprmparam.Value = ledgerPostingId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { ledgerpostinginfo.LedgerPostingId = decimal.Parse(sdrreader[0].ToString()); ledgerpostinginfo.Date = DateTime.Parse(sdrreader[1].ToString()); ledgerpostinginfo.VoucherTypeId = decimal.Parse(sdrreader[2].ToString()); ledgerpostinginfo.VoucherNo = sdrreader[3].ToString(); ledgerpostinginfo.LedgerId = decimal.Parse(sdrreader[4].ToString()); ledgerpostinginfo.Debit = decimal.Parse(sdrreader[5].ToString()); ledgerpostinginfo.Credit = decimal.Parse(sdrreader[6].ToString()); ledgerpostinginfo.DetailsId = decimal.Parse(sdrreader[8].ToString()); ledgerpostinginfo.YearId = decimal.Parse(sdrreader[9].ToString()); ledgerpostinginfo.InvoiceNo = sdrreader[10].ToString(); ledgerpostinginfo.ChequeNo = sdrreader[11].ToString(); ledgerpostinginfo.ChequeDate = DateTime.Parse(sdrreader[12].ToString()); ledgerpostinginfo.ExtraDate = DateTime.Parse(sdrreader[13].ToString()); ledgerpostinginfo.Extra1 = sdrreader[14].ToString(); ledgerpostinginfo.Extra2 = sdrreader[15].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(ledgerpostinginfo); }
/// <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; infoAccountledger.ExtraDate = PublicVariables._dtCurrentDate; 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) { formMDI.infoError.ErrorString = "MAL6:" + ex.Message; } }