/// <summary> /// Function to fill Datagridview /// </summary> public void SearchRegister() { try { string strVoucherNo = txtVoucherNo.Text.ToString(); string strToDate = string.Empty; if (txtToDate.Text == string.Empty) { strToDate = txtFromDate.Text.ToString(); } else { strToDate = txtToDate.Text.ToString(); } string strFromDate = txtFromDate.Text; DataTable dtbl = new DataTable(); DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP(); dtbl = spDebitNoteMaster.DebitNoteRegisterSearch(strVoucherNo, strFromDate, strToDate); dgvDebitNoteRegister.DataSource = dtbl; } catch (Exception ex) { MessageBox.Show("DNTREG2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// TO serch the datas and fill the grid /// </summary> public void Search() { try { if (cmbVoucherType.Items.Count != 0 && cmbAccountLedger.Items.Count != 0) { if ((cmbAccountLedger.SelectedValue.ToString() != "System.Data.DataRowView") && (cmbVoucherType.SelectedValue.ToString() != "System.Data.DataRowView")) { if (txtFromDate.Text.Trim() != string.Empty && txtToDate.Text.Trim() != string.Empty) { string strFromDate = txtFromDate.Text; string strToDate = txtToDate.Text; decimal decVoucherTypeId = Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString()); decimal decLedgerId = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString()); DataTable dtblDebitNoteReport = new DataTable(); DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP(); dtblDebitNoteReport = spDebitNoteMaster.DebitNoteReportSearch(strFromDate, strToDate, decVoucherTypeId, decLedgerId); dgvDebitNoteReport.DataSource = dtblDebitNoteReport; } } } } catch (Exception ex) { MessageBox.Show("DRNTREP5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill Datagridview /// </summary> public void SearchRegister() { try { string strVoucherNo = txtVoucherNo.Text.ToString(); string strToDate = string.Empty; if (txtToDate.Text == string.Empty) { strToDate = txtFromDate.Text.ToString(); } else { strToDate = txtToDate.Text.ToString(); } string strFromDate = txtFromDate.Text; DataTable dtbl = new DataTable(); DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP(); dtbl = spDebitNoteMaster.DebitNoteRegisterSearch(strVoucherNo, strFromDate, strToDate); dgvDebitNoteRegister.DataSource = dtbl; } catch (Exception ex) { formMDI.infoError.ErrorString = "DNTREG2:" + ex.Message; } }
/// <summary> /// Function to fill Datagridview /// </summary> public void DebitNoteRegisterGridFill() { try { DataTable dtbl = new DataTable(); DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP(); dtbl = spDebitNoteMaster.DebitNoteMasterViewAllWithSlNo(); dgvDebitNoteRegister.DataSource = dtbl; } catch (Exception ex) { MessageBox.Show("DNTREG1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill Datagridview /// </summary> public void DebitNoteRegisterGridFill() { try { DataTable dtbl = new DataTable(); DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP(); dtbl = spDebitNoteMaster.DebitNoteMasterViewAllWithSlNo(); dgvDebitNoteRegister.DataSource = dtbl; } catch (Exception ex) { formMDI.infoError.ErrorString = "DNTREG1:" + ex.Message; } }
/// <summary> /// Function to print the details /// </summary> public void Print() { try { if (dgvDebitNoteReport.Rows.Count > 0) { string strFromDate = txtFromDate.Text; string strToDate = txtToDate.Text; decimal decVoucherTypeId = Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString()); decimal decLedgerId = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString()); DebitNoteMasterSP SpDebitNoteMaster = new DebitNoteMasterSP(); DataSet dsDebitNoteReport = SpDebitNoteMaster.DebitNoteReportPrinting(strFromDate, strToDate, decVoucherTypeId, decLedgerId, 1); frmReport frmReport = new frmReport(); frmReport.MdiParent = formMDI.MDIObj; frmReport.DebitNoteReportPrinting(dsDebitNoteReport); } } catch (Exception ex) { MessageBox.Show("DRNTREP6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// function to delete voucher /// </summary> /// <param name="decDebitNoteMasterId"></param> public void DeleteFunction(decimal decDebitNoteMasterId) { try { DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP(); PartyBalanceSP spPartyBalance = new PartyBalanceSP(); if (!spPartyBalance.PartyBalanceCheckReference(decDebitNoteVoucherTypeId, strVoucherNo)) { spDebitNoteMaster.DebitNoteVoucherDelete(decDebitNoteMasterId, decDebitNoteVoucherTypeId, strVoucherNo); Messages.DeletedMessage(); if (frmDebitNoteRegisterObj != null) { this.Close(); frmDebitNoteRegisterObj.Enabled = true; } else if (frmDebitNoteReportObj != null) { this.Close(); frmDebitNoteReportObj.Enabled = true; } else if (objVoucherSearch != null) { this.Close(); objVoucherSearch.GridFill(); } else if (frmLedgerDetailsObj != null) { this.Close(); } else { Clear(); } } else { Messages.InformationMessage("Reference exist. Cannot delete"); txtDate.Focus(); } } catch (Exception ex) { MessageBox.Show("DRNT25:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On double clicking the cell in grid, it loads the corresponding Voucher to update or delete the entries /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvBillAllocation_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { decVoucherTypeId = Convert.ToDecimal(dgvBillAllocation.CurrentRow.Cells["voucherTypeId"].Value.ToString()); strTypeOfVoucher = dgvBillAllocation.CurrentRow.Cells["typeOfVoucher"].Value.ToString(); strVoucherNo = dgvBillAllocation.CurrentRow.Cells["voucherNo"].Value.ToString(); if (strTypeOfVoucher == "PDC Payable") { PDCPayableMasterSP sp = new PDCPayableMasterSP(); decimal decMasterId = sp.PdcPayableMasterIdView(decVoucherTypeId, strVoucherNo); frmPdcPayable frmpdcPayableObj = new frmPdcPayable(); frmpdcPayableObj = Application.OpenForms["frmPdcPayable"] as frmPdcPayable; if (frmpdcPayableObj == null) { frmpdcPayableObj = new frmPdcPayable(); frmpdcPayableObj.MdiParent = formMDI.MDIObj; frmpdcPayableObj.CallFromBillAllocation(this, decMasterId); } } if (strTypeOfVoucher == "PDC Receivable") { PDCReceivableMasterSP sp = new PDCReceivableMasterSP(); decimal decMasterId = sp.PdcReceivableMasterIdView(decVoucherTypeId, strVoucherNo); frmPdcReceivable frmPdcReceivableObj = new frmPdcReceivable(); frmPdcReceivableObj = Application.OpenForms["frmPdcReceivable"] as frmPdcReceivable; if (frmPdcReceivableObj == null) { frmPdcReceivableObj = new frmPdcReceivable(); frmPdcReceivableObj.MdiParent = formMDI.MDIObj; frmPdcReceivableObj.CallFromBillAllocation(this, decMasterId); } } if (strTypeOfVoucher == "Payment Voucher") { PaymentMasterSP sp = new PaymentMasterSP(); decimal decMasterId = sp.paymentMasterIdView(decVoucherTypeId, strVoucherNo); frmPaymentVoucher frmPaymentVoucherObj = new frmPaymentVoucher(); frmPaymentVoucherObj = Application.OpenForms["frmPaymentVoucher"] as frmPaymentVoucher; if (frmPaymentVoucherObj == null) { frmPaymentVoucherObj = new frmPaymentVoucher(); frmPaymentVoucherObj.MdiParent = formMDI.MDIObj; frmPaymentVoucherObj.CallFromBillAllocation(this, decMasterId); } } if (strTypeOfVoucher == "Receipt Voucher") { ReceiptMasterSP sp = new ReceiptMasterSP(); decimal decMasterId = sp.ReceiptMasterIdView(decVoucherTypeId, strVoucherNo); frmReceiptVoucher frmReceiptVoucherObj = new frmReceiptVoucher(); frmReceiptVoucherObj = Application.OpenForms["frmReceiptVoucher"] as frmReceiptVoucher; if (frmReceiptVoucherObj == null) { frmReceiptVoucherObj = new frmReceiptVoucher(); frmReceiptVoucherObj.MdiParent = formMDI.MDIObj; frmReceiptVoucherObj.CallFromBillAllocation(this, decMasterId); } } if (strTypeOfVoucher == "Journal Voucher") { JournalMasterSP sp = new JournalMasterSP(); decimal decMasterId = sp.JournalMasterIdView(decVoucherTypeId, strVoucherNo); frmJournalVoucher frmJournalVoucherObj = new frmJournalVoucher(); frmJournalVoucherObj = Application.OpenForms["frmJournalVoucher"] as frmJournalVoucher; if (frmJournalVoucherObj == null) { frmJournalVoucherObj = new frmJournalVoucher(); frmJournalVoucherObj.MdiParent = formMDI.MDIObj; frmJournalVoucherObj.CallFromBillAllocation(this, decMasterId); } } if (strTypeOfVoucher == "Credit Note") { CreditNoteMasterSP sp = new CreditNoteMasterSP(); decimal decMasterId = sp.CreditNoteMasterIdView(decVoucherTypeId, strVoucherNo); frmCreditNote frmCreditNoteObj = new frmCreditNote(); frmCreditNoteObj = Application.OpenForms["frmCreditNote"] as frmCreditNote; if (frmCreditNoteObj == null) { frmCreditNoteObj = new frmCreditNote(); frmCreditNoteObj.MdiParent = formMDI.MDIObj; frmCreditNoteObj.CallFromBillAllocation(this, decMasterId); } } if (strTypeOfVoucher == "Debit Note") { DebitNoteMasterSP sp = new DebitNoteMasterSP(); decimal decMasterId = sp.DebitNoteMasterIdView(decVoucherTypeId, strVoucherNo); frmDebitNote frmDebitNoteObj = new frmDebitNote(); frmDebitNoteObj = Application.OpenForms["frmDebitNote"] as frmDebitNote; if (frmDebitNoteObj == null) { frmDebitNoteObj = new frmDebitNote(); frmDebitNoteObj.MdiParent = formMDI.MDIObj; frmDebitNoteObj.CallFromBillAllocation(this, decMasterId); } } } } catch (Exception ex) { formMDI.infoError.ErrorString = "BA15:" + ex.Message; } }
/// <summary> /// Function to fill the fields for edit or delete /// </summary> public void FillFunction() { try { DebitNoteMasterInfo infoDebitNoteMaster = new DebitNoteMasterInfo(); DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP(); infoDebitNoteMaster = spDebitNoteMaster.DebitNoteMasterView(decDebitNoteMasterIdForEdit); txtVoucherNo.ReadOnly = false; strVoucherNo = infoDebitNoteMaster.VoucherNo; strInvoiceNo = infoDebitNoteMaster.InvoiceNo; txtVoucherNo.Text = strInvoiceNo; decDebitNoteSuffixPrefixId = infoDebitNoteMaster.SuffixPrefixId; decDebitNoteVoucherTypeId = infoDebitNoteMaster.VoucherTypeId; dtpVoucherDate.Value = infoDebitNoteMaster.Date; txtNarration.Text = infoDebitNoteMaster.Narration; VoucherTypeSP spVoucherType = new VoucherTypeSP(); isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decDebitNoteVoucherTypeId); if (isAutomatic) { txtVoucherNo.ReadOnly = true; } else { txtVoucherNo.ReadOnly = false; } //GridFill DataTable dtbl = new DataTable(); DebitNoteDetailsSP spDebitNoteDetailsSp = new DebitNoteDetailsSP(); dtbl = spDebitNoteDetailsSp.DebitNoteDetailsViewByMasterId(decDebitNoteMasterIdForEdit); AccountLedgerSP spAccountLedger = new AccountLedgerSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); for (int inI = 0; inI < dtbl.Rows.Count; inI++) { dgvDebitNote.Rows.Add(); dgvDebitNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(dtbl.Rows[inI]["ledgerId"].ToString()); if (Convert.ToDecimal(dtbl.Rows[inI]["debit"].ToString()) == 0) { dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value = "Cr"; dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(dtbl.Rows[inI]["credit"].ToString()); } else { dgvDebitNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value = "Dr"; dgvDebitNote.Rows[inI].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(dtbl.Rows[inI]["debit"].ToString()); } dgvDebitNote.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(dtbl.Rows[inI]["exchangeRateId"].ToString()); if (dtbl.Rows[inI]["chequeNo"].ToString() != string.Empty) { dgvDebitNote.Rows[inI].Cells["dgvtxtChequeNo"].Value = dtbl.Rows[inI]["chequeNo"].ToString(); dgvDebitNote.Rows[inI].Cells["dgvtxtChequeDate"].Value = (Convert.ToDateTime(dtbl.Rows[inI]["chequeDate"].ToString())).ToString(); } dgvDebitNote.Rows[inI].Cells["dgvtxtDetailsId"].Value = dtbl.Rows[inI]["DebitNoteDetailsId"].ToString(); decimal decDetailsId1 = Convert.ToDecimal(dtbl.Rows[inI]["DebitNoteDetailsId"].ToString()); decimal decLedgerPostingId = spLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decDebitNoteVoucherTypeId); dgvDebitNote.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString(); btnSave.Text = "Update"; } PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); DataTable dtbl1 = new DataTable(); dtbl1 = SpPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decDebitNoteVoucherTypeId, strVoucherNo, infoDebitNoteMaster.Date); dtblPartyBalance = dtbl1; dgvDebitNote.ClearSelection(); txtDate.Focus(); } catch (Exception ex) { MessageBox.Show("DRNT37:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <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(); DebitNoteMasterInfo infoDebitNoteMaster = new DebitNoteMasterInfo(); DebitNoteDetailsInfo infoDebitNoteDetails = new DebitNoteDetailsInfo(); ExchangeRateSP spExchangeRate = new ExchangeRateSP(); /*****************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 = spDebitNoteMaster.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--------------// LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); BankReconciliationSP spBankReconciliation = new BankReconciliationSP(); foreach (object obj in arrlstOfRemove) { string str = Convert.ToString(obj); spDebitNoteDetails.DebitNoteDetailsDelete(Convert.ToDecimal(str)); spLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(str), strVoucherNo, decDebitNoteVoucherTypeId); } spLedgerPosting.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 = spExchangeRate.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()); spDebitNoteDetails.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 = spDebitNoteDetails.DebitNoteDetailsAdd(infoDebitNoteDetails); PartyBalanceAddOrEdit(inI); LedgerPosting(decLedgerId, decCredit, decDebit, decDebitNoteDetailsId, inI); } } } Messages.UpdatedMessage(); } //----------------If print after save is enable-----------------------// SettingsSP spSettings = new SettingsSP(); if (cbxPrintAfterSave.Checked == true) { if (spSettings.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(); DebitNoteMasterInfo infoDebitNoteMaster = new DebitNoteMasterInfo(); DebitNoteDetailsInfo infoDebitNoteDetails = new DebitNoteDetailsInfo(); PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); ExchangeRateSP spExchangeRate = new ExchangeRateSP(); 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 = spDebitNoteMaster.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 = spExchangeRate.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 = spDebitNoteDetails.DebitNoteDetailsAdd(infoDebitNoteDetails); if (decDebitNoteDetailsId != 0) { PartyBalanceAddOrEdit(inI); LedgerPosting(decLedgerId, decCredit, decDebit, decDebitNoteDetailsId, inI); } } } Messages.SavedMessage(); //----------------If print after save is enable-----------------------// SettingsSP spSettings = new SettingsSP(); if (cbxPrintAfterSave.Checked == true) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decJDebitNoteMasterId); } else { Print(decJDebitNoteMasterId); } } //===================================================================// } catch (Exception ex) { MessageBox.Show("DRNT31:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On double clicking the cell in grid, it loads the corresponding Voucher to update or delete the entries /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvBillAllocation_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { decVoucherTypeId = Convert.ToDecimal(dgvBillAllocation.CurrentRow.Cells["voucherTypeId"].Value.ToString()); strTypeOfVoucher = dgvBillAllocation.CurrentRow.Cells["typeOfVoucher"].Value.ToString(); strVoucherNo = dgvBillAllocation.CurrentRow.Cells["voucherNo"].Value.ToString(); if (strTypeOfVoucher == "PDC Payable") { PDCPayableMasterSP sp = new PDCPayableMasterSP(); decimal decMasterId = sp.PdcPayableMasterIdView(decVoucherTypeId, strVoucherNo); frmPdcPayable frmpdcPayableObj = new frmPdcPayable(); frmpdcPayableObj = Application.OpenForms["frmPdcPayable"] as frmPdcPayable; if (frmpdcPayableObj == null) { frmpdcPayableObj = new frmPdcPayable(); frmpdcPayableObj.MdiParent = formMDI.MDIObj; frmpdcPayableObj.CallFromBillAllocation(this, decMasterId); } } if (strTypeOfVoucher == "PDC Receivable") { PDCReceivableMasterSP sp = new PDCReceivableMasterSP(); decimal decMasterId = sp.PdcReceivableMasterIdView(decVoucherTypeId, strVoucherNo); frmPdcReceivable frmPdcReceivableObj = new frmPdcReceivable(); frmPdcReceivableObj = Application.OpenForms["frmPdcReceivable"] as frmPdcReceivable; if (frmPdcReceivableObj == null) { frmPdcReceivableObj = new frmPdcReceivable(); frmPdcReceivableObj.MdiParent = formMDI.MDIObj; frmPdcReceivableObj.CallFromBillAllocation(this, decMasterId); } } if (strTypeOfVoucher == "Payment Voucher") { PaymentMasterSP sp = new PaymentMasterSP(); decimal decMasterId = sp.paymentMasterIdView(decVoucherTypeId, strVoucherNo); frmPaymentVoucher frmPaymentVoucherObj = new frmPaymentVoucher(); frmPaymentVoucherObj = Application.OpenForms["frmPaymentVoucher"] as frmPaymentVoucher; if (frmPaymentVoucherObj == null) { frmPaymentVoucherObj = new frmPaymentVoucher(); frmPaymentVoucherObj.MdiParent = formMDI.MDIObj; frmPaymentVoucherObj.CallFromBillAllocation(this, decMasterId); } } if (strTypeOfVoucher == "Receipt Voucher") { ReceiptMasterSP sp = new ReceiptMasterSP(); decimal decMasterId = sp.ReceiptMasterIdView(decVoucherTypeId, strVoucherNo); frmReceiptVoucher frmReceiptVoucherObj = new frmReceiptVoucher(); frmReceiptVoucherObj = Application.OpenForms["frmReceiptVoucher"] as frmReceiptVoucher; if (frmReceiptVoucherObj == null) { frmReceiptVoucherObj = new frmReceiptVoucher(); frmReceiptVoucherObj.MdiParent = formMDI.MDIObj; frmReceiptVoucherObj.CallFromBillAllocation(this, decMasterId); } } if (strTypeOfVoucher == "Journal Voucher") { JournalMasterSP sp = new JournalMasterSP(); decimal decMasterId = sp.JournalMasterIdView(decVoucherTypeId, strVoucherNo); frmJournalVoucher frmJournalVoucherObj = new frmJournalVoucher(); frmJournalVoucherObj = Application.OpenForms["frmJournalVoucher"] as frmJournalVoucher; if (frmJournalVoucherObj == null) { frmJournalVoucherObj = new frmJournalVoucher(); frmJournalVoucherObj.MdiParent = formMDI.MDIObj; frmJournalVoucherObj.CallFromBillAllocation(this, decMasterId); } } if (strTypeOfVoucher == "Credit Note") { CreditNoteMasterSP sp = new CreditNoteMasterSP(); decimal decMasterId = sp.CreditNoteMasterIdView(decVoucherTypeId, strVoucherNo); frmCreditNote frmCreditNoteObj = new frmCreditNote(); frmCreditNoteObj = Application.OpenForms["frmCreditNote"] as frmCreditNote; if (frmCreditNoteObj == null) { frmCreditNoteObj = new frmCreditNote(); frmCreditNoteObj.MdiParent = formMDI.MDIObj; frmCreditNoteObj.CallFromBillAllocation(this, decMasterId); } } if (strTypeOfVoucher == "Debit Note") { DebitNoteMasterSP sp = new DebitNoteMasterSP(); decimal decMasterId = sp.DebitNoteMasterIdView(decVoucherTypeId, strVoucherNo); frmDebitNote frmDebitNoteObj = new frmDebitNote(); frmDebitNoteObj = Application.OpenForms["frmDebitNote"] as frmDebitNote; if (frmDebitNoteObj == null) { frmDebitNoteObj = new frmDebitNote(); frmDebitNoteObj.MdiParent = formMDI.MDIObj; frmDebitNoteObj.CallFromBillAllocation(this, decMasterId); } } } } catch (Exception ex) { MessageBox.Show("BA:15" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// When doubleclicking on the grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvReport_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { decimal decVouchertypeId = 0; string strVoucherNo = string.Empty; try { if (dgvReport.CurrentRow.Index == e.RowIndex) { if ((dgvReport.CurrentRow.Cells["voucherTypeId"].Value != null && dgvReport.CurrentRow.Cells["voucherTypeId"].Value.ToString() != string.Empty)) { int inI = dgvReport.CurrentCell.RowIndex; foreach (DataGridViewRow dgv in dgvReport.Rows) { if (dgv.Cells["VoucherNo"].Value != null && dgv.Cells["VoucherNo"].Value.ToString() != string.Empty && dgv.Cells["voucherTypeId"].Value != null && dgv.Cells["voucherTypeId"].Value.ToString() != string.Empty) { strVoucherType = dgv.Cells["VoucherType"].Value.ToString(); decVouchertypeId = Convert.ToDecimal(dgv.Cells["voucherTypeId"].Value.ToString()); strVoucherNo = dgv.Cells["VoucherNo"].Value.ToString(); } else { if (dgv.Cells["ledgerId"].Value.ToString() != string.Empty) { decledgerId = decimal.Parse(dgv.Cells["ledgerId"].Value.ToString()); strVoucherType = dgv.Cells["Account Ledger"].Value.ToString(); frmLedgerDetails frmLedger = new frmLedgerDetails(); frmLedger = Application.OpenForms["frmLedgerDetails"] as frmLedgerDetails; if (frmLedger == null) { frmLedger = new frmLedgerDetails(); frmLedger.MdiParent = formMDI.MDIObj; frmLedger.callFromAgeing(this, decledgerId); this.Enabled = false; } } } if (dgv.Index == inI) { break; } } if (strVoucherType == "Payment Voucher") { PaymentMasterSP spPaymentMaster = new PaymentMasterSP(); decMasterId = spPaymentMaster.paymentMasterIdView(decVouchertypeId, strVoucherNo); frmPaymentVoucher frmPaymentVoucher = new frmPaymentVoucher(); frmPaymentVoucher = Application.OpenForms["frmPaymentVoucher"] as frmPaymentVoucher; if (frmPaymentVoucher == null) { frmPaymentVoucher = new frmPaymentVoucher(); frmPaymentVoucher.MdiParent = formMDI.MDIObj; frmPaymentVoucher.callFromAgeing(this, decMasterId); this.Enabled = false; } } else if (strVoucherType == "Receipt Voucher") { ReceiptMasterSP spRecieptMaster = new ReceiptMasterSP(); decMasterId = spRecieptMaster.ReceiptMasterIdView(decVouchertypeId, strVoucherNo); frmReceiptVoucher frmReceiptVoucher = new frmReceiptVoucher(); frmReceiptVoucher = Application.OpenForms["frmReceiptVoucher"] as frmReceiptVoucher; if (frmReceiptVoucher == null) { frmReceiptVoucher = new frmReceiptVoucher(); frmReceiptVoucher.MdiParent = formMDI.MDIObj; frmReceiptVoucher.callFromAgeing(this, decMasterId); this.Enabled = false; } } else if (strVoucherType == "Journal Voucher") { JournalMasterSP spJournalMaster = new JournalMasterSP(); decMasterId = spJournalMaster.JournalMasterIdView(decVouchertypeId, strVoucherNo); frmJournalVoucher frmJournalVoucher = new frmJournalVoucher(); frmJournalVoucher = Application.OpenForms["frmJournalVoucher"] as frmJournalVoucher; if (frmJournalVoucher == null) { frmJournalVoucher = new frmJournalVoucher(); frmJournalVoucher.MdiParent = formMDI.MDIObj; frmJournalVoucher.callFromAgeing(this, decMasterId); this.Enabled = false; } } else if (strVoucherType == "PDC Receivable") { PDCReceivableMasterSP spPdcRecievabl = new PDCReceivableMasterSP(); decMasterId = spPdcRecievabl.PdcReceivableMasterIdView(decVouchertypeId, strVoucherNo); frmPdcReceivable frmPdcReceivable = new frmPdcReceivable(); frmPdcReceivable = Application.OpenForms["frmPdcReceivable"] as frmPdcReceivable; if (frmPdcReceivable == null) { frmPdcReceivable = new frmPdcReceivable(); frmPdcReceivable.MdiParent = formMDI.MDIObj; frmPdcReceivable.callFromAgeing(this, decMasterId); this.Enabled = false; } } else if (strVoucherType == "PDC Payable") { PDCPayableMasterSP spPdcPayable = new PDCPayableMasterSP(); decMasterId = spPdcPayable.PdcPayableMasterIdView(decVouchertypeId, strVoucherNo); frmPdcPayable frmPdcPayable = new frmPdcPayable(); frmPdcPayable = Application.OpenForms["frmPdcPayable"] as frmPdcPayable; if (frmPdcPayable == null) { frmPdcPayable = new frmPdcPayable(); frmPdcPayable.MdiParent = formMDI.MDIObj; frmPdcPayable.callFromAgeing(this, decMasterId); this.Enabled = false; } } else if (strVoucherType == "Sales Invoice") { SalesMasterSP spMaster = new SalesMasterSP(); decMasterId = spMaster.SalesMasterIdViewByvoucherNoAndVoucherType(decVouchertypeId, strVoucherNo); SalesMasterSP spSalesMaster = new SalesMasterSP(); bool blPOS = spSalesMaster.DayBookSalesInvoiceOrPOS(decMasterId, decVouchertypeId); frmSalesInvoice frmSalesInvoice = new frmSalesInvoice(); frmPOS frmPOS = new frmPOS(); if (blPOS == true) { frmPOS = Application.OpenForms["frmPOS"] as frmPOS; if (frmPOS == null) { frmPOS = new frmPOS(); frmPOS.MdiParent = formMDI.MDIObj; frmPOS.callFromAgeing(this, decMasterId); this.Enabled = false; } } else { frmSalesInvoice = Application.OpenForms["frmSalesInvoice"] as frmSalesInvoice; if (frmSalesInvoice == null) { frmSalesInvoice = new frmSalesInvoice(); frmSalesInvoice.MdiParent = formMDI.MDIObj; frmSalesInvoice.callFromAgeing(this, decMasterId); this.Enabled = false; } } } else if (strVoucherType == "Purchase Invoice") { PurchaseMasterSP spPurchaseMaster = new PurchaseMasterSP(); decMasterId = spPurchaseMaster.PurchaseMasterIdViewByvoucherNoAndVoucherType(decVouchertypeId, strVoucherNo); frmPurchaseInvoice objpurchase = new frmPurchaseInvoice(); objpurchase.WindowState = FormWindowState.Normal; objpurchase.MdiParent = formMDI.MDIObj; objpurchase.callFromAgeing(this, decMasterId); this.Enabled = false; } else if (strVoucherType == "Credit Note") { CreditNoteMasterSP spCreditNoteMaster = new CreditNoteMasterSP(); decMasterId = spCreditNoteMaster.CreditNoteMasterIdView(decVouchertypeId, strVoucherNo); frmCreditNote objpurchase = new frmCreditNote(); objpurchase.WindowState = FormWindowState.Normal; objpurchase.MdiParent = formMDI.MDIObj; objpurchase.callFromAgeing(this, decMasterId); this.Enabled = false; } else if (strVoucherType == "Debit Note") { DebitNoteMasterSP spDebitNote = new DebitNoteMasterSP(); decMasterId = spDebitNote.DebitNoteMasterIdView(decVouchertypeId, strVoucherNo); frmDebitNote objpurchase = new frmDebitNote(); objpurchase.WindowState = FormWindowState.Normal; objpurchase.MdiParent = formMDI.MDIObj; objpurchase.callFromAgeing(this, decMasterId); this.Enabled = false; } } } } catch (Exception ex) { MessageBox.Show("AR17:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to clear the fields /// </summary> public void Clear() { try { TransactionsGeneralFill obj = new TransactionsGeneralFill(); DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP(); //-----------------------------------VoucherNo automatic generation-------------------------------------------// if (strVoucherNo == string.Empty) { strVoucherNo = "0"; //strMax; } strVoucherNo = obj.VoucherNumberAutomaicGeneration(decDebitNoteVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName); if (Convert.ToDecimal(strVoucherNo) != spDebitNoteMaster.DebitNoteMasterGetMaxPlusOne(decDebitNoteVoucherTypeId)) { strVoucherNo = spDebitNoteMaster.DebitNoteMasterGetMax(decDebitNoteVoucherTypeId).ToString(); strVoucherNo = obj.VoucherNumberAutomaicGeneration(decDebitNoteVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName); if (spDebitNoteMaster.DebitNoteMasterGetMax(decDebitNoteVoucherTypeId).ToString() == "0") { strVoucherNo = "0"; strVoucherNo = obj.VoucherNumberAutomaicGeneration(decDebitNoteVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName); } } //===================================================================================================================// if (isAutomatic) { SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP(); SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo(); infoSuffixPrefix = spSuffisprefix.GetSuffixPrefixDetails(decDebitNoteVoucherTypeId, dtpVoucherDate.Value); strPrefix = infoSuffixPrefix.Prefix; strSuffix = infoSuffixPrefix.Suffix; strInvoiceNo = strPrefix + strVoucherNo + strSuffix; txtVoucherNo.Text = strInvoiceNo; txtVoucherNo.ReadOnly = true; } else { txtVoucherNo.ReadOnly = false; txtVoucherNo.Text = string.Empty; strInvoiceNo = txtVoucherNo.Text; } dgvDebitNote.Rows.Clear(); VoucherDate(); dtpVoucherDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy"); txtDebitTotal.Text = string.Empty; txtCreditTotal.Text = string.Empty; btnSave.Text = "Save"; btnDelete.Enabled = false; isEditMode = false; dtblPartyBalance.Clear();//To clear party balance entries to clear the dgvpartybalance PrintCheck(); if (!txtVoucherNo.ReadOnly) { txtVoucherNo.Focus(); } else { txtDate.Select(); } txtNarration.Text = string.Empty; } catch (Exception ex) { MessageBox.Show("DRNT3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to determine whether to call SaveFunction or EditFunction function /// </summary> public void SaveOrEditFunction() { try { DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP(); if (!isEditMode) { if (txtVoucherNo.Text.Trim() != string.Empty) { if (!isAutomatic) { strInvoiceNo = txtVoucherNo.Text.Trim(); if (!spDebitNoteMaster.DebitNoteVoucherCheckExistance(strInvoiceNo, decDebitNoteVoucherTypeId, 0)) { SaveFunction(); } else { Messages.InformationMessage("Voucher number already exist"); } } else { SaveFunction(); } } else { Messages.InformationMessage("Enter voucherNo"); txtVoucherNo.Focus(); } } else { if (txtVoucherNo.Text.Trim() != string.Empty) { if (!isAutomatic) { strInvoiceNo = txtVoucherNo.Text.Trim(); if (!spDebitNoteMaster.DebitNoteVoucherCheckExistance(strInvoiceNo, decDebitNoteVoucherTypeId, decDebitNoteMasterIdForEdit)) { EditFunction(decDebitNoteMasterIdForEdit); } else { Messages.InformationMessage("Voucher number already exist"); } } else { EditFunction(decDebitNoteMasterIdForEdit); } } else { Messages.InformationMessage("Enter voucherNo"); } } } catch (Exception ex) { MessageBox.Show("DRNT21:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to print the voucher /// </summary> /// <param name="decMasterId"></param> public void Print(decimal decMasterId) { try { DebitNoteMasterSP SpDebitNoteMaster = new DebitNoteMasterSP(); DataSet dsDebitNoteVoucher = SpDebitNoteMaster.DebitNotePrinting(decMasterId, 1); frmReport frmReport = new frmReport(); frmReport.MdiParent = formMDI.MDIObj; frmReport.DebitNotePrinting(dsDebitNoteVoucher); } catch (Exception ex) { MessageBox.Show("DRNT26:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }