public void DebitNoteDetailsEdit(DebitNoteDetailsInfo debitnotedetailsinfo) { try { spDebitNoteDetails.DebitNoteDetailsEdit(debitnotedetailsinfo); } catch (Exception ex) { MessageBox.Show("DNBLL:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public decimal DebitNoteDetailsAdd(DebitNoteDetailsInfo debitnotedetailsinfo) { decimal decDebitNoteDetails = 0; try { decDebitNoteDetails = spDebitNoteDetails.DebitNoteDetailsAdd(debitnotedetailsinfo); } catch (Exception ex) { MessageBox.Show("DNBLL:1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(decDebitNoteDetails); }
/// <summary> /// Function to insert values to DebitNoteDetails Table /// </summary> /// <param name="debitnotedetailsinfo"></param> /// <returns></returns> public decimal DebitNoteDetailsAdd(DebitNoteDetailsInfo debitnotedetailsinfo) { decimal decDebitNoteDetails = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("DebitNoteDetailsAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@debitNoteMasterId", SqlDbType.Decimal); sprmparam.Value = debitnotedetailsinfo.DebitNoteMasterId; sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam.Value = debitnotedetailsinfo.LedgerId; sprmparam = sccmd.Parameters.Add("@credit", SqlDbType.Decimal); sprmparam.Value = debitnotedetailsinfo.Credit; sprmparam = sccmd.Parameters.Add("@debit", SqlDbType.Decimal); sprmparam.Value = debitnotedetailsinfo.Debit; sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal); sprmparam.Value = debitnotedetailsinfo.ExchangeRateId; sprmparam = sccmd.Parameters.Add("@chequeNo", SqlDbType.VarChar); sprmparam.Value = debitnotedetailsinfo.ChequeNo; sprmparam = sccmd.Parameters.Add("@chequeDate", SqlDbType.DateTime); sprmparam.Value = debitnotedetailsinfo.ChequeDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = debitnotedetailsinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = debitnotedetailsinfo.Extra2; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = debitnotedetailsinfo.ExtraDate; decDebitNoteDetails = Convert.ToDecimal(sccmd.ExecuteScalar().ToString()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(decDebitNoteDetails); }
public void DebitNoteDetailsEdit(DebitNoteDetailsInfo debitnotedetailsinfo) { try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("DebitNoteDetailsEdit", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam12 = new SqlParameter(); sprmparam12 = sccmd.Parameters.Add("@debitNoteDetailsId", SqlDbType.Decimal); sprmparam12.Value = debitnotedetailsinfo.DebitNoteDetailsId; sprmparam12 = sccmd.Parameters.Add("@debitNoteMasterId", SqlDbType.Decimal); sprmparam12.Value = debitnotedetailsinfo.DebitNoteMasterId; sprmparam12 = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam12.Value = debitnotedetailsinfo.LedgerId; sprmparam12 = sccmd.Parameters.Add("@credit", SqlDbType.Decimal); sprmparam12.Value = debitnotedetailsinfo.Credit; sprmparam12 = sccmd.Parameters.Add("@debit", SqlDbType.Decimal); sprmparam12.Value = debitnotedetailsinfo.Debit; sprmparam12 = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal); sprmparam12.Value = debitnotedetailsinfo.ExchangeRateId; sprmparam12 = sccmd.Parameters.Add("@chequeNo", SqlDbType.VarChar); sprmparam12.Value = debitnotedetailsinfo.ChequeNo; sprmparam12 = sccmd.Parameters.Add("@chequeDate", SqlDbType.DateTime); sprmparam12.Value = debitnotedetailsinfo.ChequeDate; sprmparam12 = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam12.Value = debitnotedetailsinfo.Extra1; sprmparam12 = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam12.Value = debitnotedetailsinfo.Extra2; sprmparam12 = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam12.Value = debitnotedetailsinfo.ExtraDate; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { base.sqlcon.Close(); } }
public DebitNoteDetailsInfo DebitNoteDetailsView(decimal debitNoteDetailsId) { DebitNoteDetailsInfo debitnotedetailsinfo = new DebitNoteDetailsInfo(); SqlDataReader sdrreader = null; try { if (base.sqlcon.State == ConnectionState.Closed) { base.sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("DebitNoteDetailsView", base.sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam2 = new SqlParameter(); sprmparam2 = sccmd.Parameters.Add("@debitNoteDetailsId", SqlDbType.Decimal); sprmparam2.Value = debitNoteDetailsId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { debitnotedetailsinfo.DebitNoteDetailsId = decimal.Parse(((DbDataReader)sdrreader)[0].ToString()); debitnotedetailsinfo.DebitNoteMasterId = decimal.Parse(((DbDataReader)sdrreader)[1].ToString()); debitnotedetailsinfo.LedgerId = decimal.Parse(((DbDataReader)sdrreader)[2].ToString()); debitnotedetailsinfo.Credit = decimal.Parse(((DbDataReader)sdrreader)[3].ToString()); debitnotedetailsinfo.Debit = decimal.Parse(((DbDataReader)sdrreader)[4].ToString()); debitnotedetailsinfo.ExchangeRateId = decimal.Parse(((DbDataReader)sdrreader)[5].ToString()); debitnotedetailsinfo.ChequeNo = ((DbDataReader)sdrreader)[6].ToString(); debitnotedetailsinfo.ChequeDate = DateTime.Parse(((DbDataReader)sdrreader)[7].ToString()); debitnotedetailsinfo.Extra1 = ((DbDataReader)sdrreader)[8].ToString(); debitnotedetailsinfo.Extra2 = ((DbDataReader)sdrreader)[9].ToString(); debitnotedetailsinfo.ExtraDate = DateTime.Parse(((DbDataReader)sdrreader)[10].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); base.sqlcon.Close(); } return(debitnotedetailsinfo); }
/// <summary> /// Function to edit the debitnote voucher /// </summary> /// <param name="decDebitNoteMasterId"></param> public void Edit(decimal decDebitNoteMasterId) { try { //DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP(); //DebitNoteDetailsSP spDebitNoteDetails = new DebitNoteDetailsSP(); DebitNoteBll bllDebitNote = new DebitNoteBll(); DebitNoteMasterInfo infoDebitNoteMaster = new DebitNoteMasterInfo(); DebitNoteDetailsInfo infoDebitNoteDetails = new DebitNoteDetailsInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); /*****************Update in DebitNoteMaster table *************/ decimal decTotalDebit = 0; decimal decTotalCredit = 0; infoDebitNoteMaster.DebitNoteMasterId = decDebitNoteMasterId; infoDebitNoteMaster.VoucherNo = strVoucherNo; infoDebitNoteMaster.InvoiceNo = txtVoucherNo.Text.Trim(); infoDebitNoteMaster.SuffixPrefixId = decDebitNoteSuffixPrefixId; infoDebitNoteMaster.Date = Convert.ToDateTime(txtDate.Text); infoDebitNoteMaster.Narration = txtNarration.Text; infoDebitNoteMaster.UserId = PublicVariables._decCurrentUserId; infoDebitNoteMaster.VoucherTypeId = decDebitNoteVoucherTypeId; infoDebitNoteMaster.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString()); infoDebitNoteMaster.ExtraDate = DateTime.Now; infoDebitNoteMaster.Extra1 = string.Empty; infoDebitNoteMaster.Extra2 = string.Empty; decTotalDebit = Convert.ToDecimal(txtDebitTotal.Text.Trim()); decTotalCredit = Convert.ToDecimal(txtCreditTotal.Text.Trim()); infoDebitNoteMaster.TotalAmount = decTotalDebit; decimal decEffectRow = bllDebitNote.DebitNoteMasterEdit(infoDebitNoteMaster); /**********************DebitNoteDetails Edit********************/ if (decEffectRow > 0) { infoDebitNoteDetails.DebitNoteMasterId = decDebitNoteMasterId; infoDebitNoteDetails.ExtraDate = DateTime.Now; infoDebitNoteDetails.Extra1 = string.Empty; infoDebitNoteDetails.Extra2 = string.Empty; //-----------to delete details, LedgerPosting and bankReconciliation of removed rows--------------// LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); BankReconciliationBll BllBankReconciliation = new BankReconciliationBll(); foreach (object obj in arrlstOfRemove) { string str = Convert.ToString(obj); bllDebitNote.DebitNoteDetailsDelete(Convert.ToDecimal(str)); BllLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(str), strVoucherNo, decDebitNoteVoucherTypeId); } BllLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decDebitNoteVoucherTypeId, 12); //=============================================================================================// decimal decLedgerId = 0; decimal decDebit = 0; decimal decCredit = 0; decimal decDebitNoteDetailsId = 0; int inRowCount = dgvDebitNote.RowCount; for (int inI = 0; inI < inRowCount; inI++) { if (dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { infoDebitNoteDetails.LedgerId = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); decLedgerId = infoDebitNoteDetails.LedgerId; } if (dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() != string.Empty) { //------------------Currency conversion------------------// decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvcmbCurrency"].Value)); decAmount = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); decConvertRate = decAmount * decSelectedCurrencyRate; //======================================================// if (dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() == "Dr") { infoDebitNoteDetails.Debit = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoDebitNoteDetails.Credit = 0; decDebit = decConvertRate; decCredit = infoDebitNoteDetails.Credit; } else { infoDebitNoteDetails.Credit = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoDebitNoteDetails.Debit = 0; decDebit = infoDebitNoteDetails.Debit; decCredit = decConvertRate; } infoDebitNoteDetails.ExchangeRateId = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()); if (dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { infoDebitNoteDetails.ChequeNo = dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString(); } else { infoDebitNoteDetails.ChequeNo = string.Empty; } if (dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty) { infoDebitNoteDetails.ChequeDate = Convert.ToDateTime(dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value); } else { infoDebitNoteDetails.ChequeDate = DateTime.Now; } if (dgvDebitNote.Rows[inI].Cells["dgvtxtDetailsId"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString() != string.Empty) { infoDebitNoteDetails.DebitNoteDetailsId = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString()); bllDebitNote.DebitNoteDetailsEdit(infoDebitNoteDetails); PartyBalanceAddOrEdit(inI); decDebitNoteDetailsId = infoDebitNoteDetails.DebitNoteDetailsId; decimal decLedgerPostId = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value.ToString()); LedgerPostingEdit(decLedgerPostId, decLedgerId, decCredit, decDebit, decDebitNoteDetailsId, inI); } else { decDebitNoteDetailsId = bllDebitNote.DebitNoteDetailsAdd(infoDebitNoteDetails); PartyBalanceAddOrEdit(inI); LedgerPosting(decLedgerId, decCredit, decDebit, decDebitNoteDetailsId, inI); } } } Messages.UpdatedMessage(); } //----------------If print after save is enable-----------------------// SettingsBll BllSettings = new SettingsBll(); if (cbxPrintAfterSave.Checked == true) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(infoDebitNoteMaster.DebitNoteMasterId); } else { Print(infoDebitNoteMaster.DebitNoteMasterId); } } //===================================================================// if (frmDebitNoteRegisterObj != null) { this.Close(); frmDebitNoteRegisterObj.Enabled = true; } else if (frmDebitNoteReportObj != null) { this.Close(); frmDebitNoteReportObj.Enabled = true; } else { Clear(); } } catch (Exception ex) { MessageBox.Show("DRNT34:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save the debitnote voucher /// </summary> public void Save() { try { decimal decTotalDebit = 0; decimal decTotalCredit = 0; decTotalDebit = Convert.ToDecimal(txtDebitTotal.Text.Trim()); decTotalCredit = Convert.ToDecimal(txtCreditTotal.Text.Trim()); //DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP(); //DebitNoteDetailsSP spDebitNoteDetails = new DebitNoteDetailsSP(); DebitNoteBll bllDebitNote = new DebitNoteBll(); DebitNoteMasterInfo infoDebitNoteMaster = new DebitNoteMasterInfo(); DebitNoteDetailsInfo infoDebitNoteDetails = new DebitNoteDetailsInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); infoDebitNoteMaster.VoucherNo = strVoucherNo; infoDebitNoteMaster.InvoiceNo = txtVoucherNo.Text.Trim(); infoDebitNoteMaster.SuffixPrefixId = decDebitNoteSuffixPrefixId; infoDebitNoteMaster.Date = Convert.ToDateTime(txtDate.Text); infoDebitNoteMaster.Narration = txtNarration.Text; infoDebitNoteMaster.UserId = PublicVariables._decCurrentUserId; infoDebitNoteMaster.VoucherTypeId = decDebitNoteVoucherTypeId; infoDebitNoteMaster.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString()); infoDebitNoteMaster.Extra1 = string.Empty; infoDebitNoteMaster.Extra2 = string.Empty; infoDebitNoteMaster.TotalAmount = decTotalDebit; decimal decJDebitNoteMasterId = bllDebitNote.DebitNoteMasterAdd(infoDebitNoteMaster); /*******************DebitNoteDetailsAdd and LedgerPosting*************************/ infoDebitNoteDetails.DebitNoteMasterId = decJDebitNoteMasterId; infoDebitNoteDetails.ExtraDate = DateTime.Now; infoDebitNoteDetails.Extra1 = string.Empty; infoDebitNoteDetails.Extra2 = string.Empty; decimal decLedgerId = 0; decimal decDebit = 0; decimal decCredit = 0; int inRowCount = dgvDebitNote.RowCount; for (int inI = 0; inI < inRowCount - 1; inI++) { if (dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { infoDebitNoteDetails.LedgerId = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); decLedgerId = infoDebitNoteDetails.LedgerId; } if (dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() != string.Empty) { if (dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString() != string.Empty) { //--------Currency conversion--------------// decSelectedCurrencyRate = BllExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString())); decAmount = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); decConvertRate = decAmount * decSelectedCurrencyRate; //===========================================// if (dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() == "Dr") { infoDebitNoteDetails.Debit = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoDebitNoteDetails.Credit = 0; decDebit = decConvertRate; decCredit = infoDebitNoteDetails.Credit; } else { infoDebitNoteDetails.Credit = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoDebitNoteDetails.Debit = 0; decDebit = infoDebitNoteDetails.Debit; decCredit = decConvertRate; } } infoDebitNoteDetails.ExchangeRateId = Convert.ToDecimal(dgvDebitNote.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()); if (dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { infoDebitNoteDetails.ChequeNo = dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString(); } else { infoDebitNoteDetails.ChequeNo = string.Empty; } if (dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty) { infoDebitNoteDetails.ChequeDate = Convert.ToDateTime(dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value); } else { infoDebitNoteDetails.ChequeDate = DateTime.Now; } decimal decDebitNoteDetailsId = bllDebitNote.DebitNoteDetailsAdd(infoDebitNoteDetails); if (decDebitNoteDetailsId != 0) { PartyBalanceAddOrEdit(inI); LedgerPosting(decLedgerId, decCredit, decDebit, decDebitNoteDetailsId, inI); } } } Messages.SavedMessage(); //----------------If print after save is enable-----------------------// SettingsBll BllSettings = new SettingsBll(); if (cbxPrintAfterSave.Checked == true) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decJDebitNoteMasterId); } else { Print(decJDebitNoteMasterId); } } //===================================================================// } catch (Exception ex) { MessageBox.Show("DRNT31:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }