/// <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") { PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll(); decMasterId = BllPaymentVoucher.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") { RecieptVoucherBll bllRecieptVoucher = new RecieptVoucherBll(); //ReceiptMasterSP spRecieptMaster = new ReceiptMasterSP(); decMasterId = bllRecieptVoucher.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") { JournalVoucherBll bllJournalMaster = new JournalVoucherBll(); decMasterId = bllJournalMaster.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") { PDCRecivebleBll BllPDCReciveble = new PDCRecivebleBll(); decMasterId = BllPDCReciveble.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") { PDCPayableBll BllPDCPayable = new PDCPayableBll(); decMasterId = BllPDCPayable.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(); SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll(); decMasterId = BllSalesInvoice.SalesMasterIdViewByvoucherNoAndVoucherType(decVouchertypeId, strVoucherNo); //SalesMasterSP spSalesMaster = new SalesMasterSP(); bool blPOS = BllSalesInvoice.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") { PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll(); decMasterId = BllPurchaseInvoice.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") { CreditNoteBll BllCreditNoteMaster = new CreditNoteBll(); decMasterId = BllCreditNoteMaster.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(); DebitNoteBll bllDebitNote = new DebitNoteBll(); decMasterId = bllDebitNote.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> /// Edit Function /// </summary> /// <param name="decMasterId"></param> public void Edit(decimal decMasterId) { try { int inRowCount = dgvPaymentVoucher.RowCount; int inTableRowCount = dtblPartyBalance.Rows.Count; int inB = 0; PaymentMasterInfo InfoPaymentMaster = new PaymentMasterInfo(); //PaymentMasterSP SpPaymentMaster = new PaymentMasterSP(); PaymentDetailsInfo InfoPaymentDetails = new PaymentDetailsInfo(); //PaymentDetailsSP SpPaymentDetails = new PaymentDetailsSP(); PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); LedgerPostingInfo InfoLegerPosting = new LedgerPostingInfo(); PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); BankReconciliationBll BllBankReconcilation = new BankReconciliationBll(); InfoPaymentMaster.Date = dtpDate.Value; InfoPaymentMaster.PaymentMasterId = decMasterId; InfoPaymentMaster.Extra1 = string.Empty; InfoPaymentMaster.Extra2 = string.Empty; InfoPaymentMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoPaymentMaster.InvoiceNo = txtVoucherNo.Text.Trim(); InfoPaymentMaster.LedgerId = Convert.ToDecimal(cmbBankorCash.SelectedValue.ToString()); InfoPaymentMaster.Narration = txtNarration.Text.Trim(); InfoPaymentMaster.SuffixPrefixId = decDailySuffixPrefixId; decimal decTotalAmount = TotalAmountCalculation(); InfoPaymentMaster.TotalAmount = decTotalAmount; InfoPaymentMaster.UserId = PublicVariables._decCurrentUserId; InfoPaymentMaster.VoucherNo = strVoucherNo; InfoPaymentMaster.VoucherTypeId = decPaymentVoucherTypeId; decimal decPaymentMasterId = BllPaymentVoucher.PaymentMasterEdit(InfoPaymentMaster); if (decPaymentmasterId != 0) { MasterLedgerPostingEdit(); } foreach (object obj in arrlstOfRemove) { string str = Convert.ToString(obj); BllPaymentVoucher.PaymentDetailsDelete(Convert.ToDecimal(str)); BllLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(str), strVoucherNo, decPaymentVoucherTypeId); } BllLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decPaymentVoucherTypeId, 12); decimal decPaymentDetailsId1 = 0; for (int inI = 0; inI < inRowCount - 1; inI++) { InfoPaymentDetails.Amount = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); InfoPaymentDetails.ExchangeRateId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()); InfoPaymentDetails.Extra1 = string.Empty; InfoPaymentDetails.Extra2 = string.Empty; if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { InfoPaymentDetails.LedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); } if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { InfoPaymentDetails.ChequeNo = dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString(); if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty) { InfoPaymentDetails.ChequeDate = Convert.ToDateTime(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value); } else { InfoPaymentDetails.ChequeDate = DateTime.Now; } } else { InfoPaymentDetails.ChequeNo = string.Empty; InfoPaymentDetails.ChequeDate = DateTime.Now; } InfoPaymentDetails.PaymentMasterId = decPaymentMasterId; if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].FormattedValue.ToString() == "0")//if new rows are added { if (dgvPaymentVoucher.Rows[inI].HeaderCell.Value.ToString() != "X")//add new rows added which are completed { decimal decPaymentDetailsId = BllPaymentVoucher.PaymentDetailsAdd(InfoPaymentDetails);//to add new rows in payment details if (decPaymentDetailsId != 0) { for (int inJ = 0; inJ < inTableRowCount; inJ++) { if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString()) { PartyBalanceAddOrEdit(inJ); } } inB++; DetailsLedgerPosting(inI, decPaymentDetailsId);//to add new ledger posting } } } else { if (dgvPaymentVoucher.Rows[inI].HeaderCell.Value != null && dgvPaymentVoucher.Rows[inI].HeaderCell.Value.ToString() != "X")//add new rows updated which are completed { InfoPaymentDetails.PaymentDetailsId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].Value.ToString()); decimal decPaymentDetailsId = BllPaymentVoucher.PaymentDetailsEdit(InfoPaymentDetails);//to edit rows if (decPaymentDetailsId != 0) { for (int inJ = 0; inJ < inTableRowCount; inJ++) { if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString()) { PartyBalanceAddOrEdit(inJ); } } inB++; decPaymentDetailsId1 = InfoPaymentDetails.PaymentDetailsId; decimal decLedgerPostId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value.ToString()); DetailsLedgerPostingEdit(inI, decLedgerPostId, decPaymentDetailsId1); } } else { decimal decDetailsId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].Value.ToString()); BllPaymentVoucher.PaymentDetailsDelete(decDetailsId); BllLedgerPosting.LedgerPostDeleteByDetailsId(decDetailsId, strVoucherNo, decPaymentVoucherTypeId); for (int inJ = 0; inJ < dtblPartyBalance.Rows.Count; inJ++) { if (dtblPartyBalance.Rows.Count == inJ) { break; } if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { if (dtblPartyBalance.Rows[inJ]["LedgerId"].ToString() == dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()) { if (dtblPartyBalance.Rows[inJ]["PartyBalanceId"].ToString() != "0") { arrlstOfDeletedPartyBalanceRow.Add(dtblPartyBalance.Rows[inJ]["PartyBalanceId"]); } } } } } } } DeletePartyBalanceOfRemovedRow(); isUpdated = true; Messages.UpdatedMessage(); if (cbxPrintafterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPaymentmasterId); } else { Print(decPaymentMasterId); } } if (frmPaymentRegisterObj != null) { this.Close(); frmPaymentRegisterObj.CallFromPaymentVoucher(this); } if (frmPaymentReportObj != null) { this.Close(); frmPaymentReportObj.CallFromPaymentVoucher(this); } if (frmDayBookObj != null) { this.Close(); } if (frmBillallocationObj != null) { this.Close(); } this.Close(); } catch (Exception ex) { MessageBox.Show("PV18:" + 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") { PDCPayableBll BllPDCPayable = new PDCPayableBll(); decimal decMasterId = BllPDCPayable.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") { PDCRecivebleBll BllPDCReciveble = new PDCRecivebleBll(); decimal decMasterId = BllPDCReciveble.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") { PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll(); decimal decMasterId = BllPaymentVoucher.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") { RecieptVoucherBll bllRecieptVoucherBll = new RecieptVoucherBll(); decimal decMasterId = bllRecieptVoucherBll.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") { JournalVoucherBll JournalVoucherbll = new JournalVoucherBll(); decimal decMasterId = JournalVoucherbll.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") { CreditNoteBll BllCreditNoteMaster = new CreditNoteBll(); decimal decMasterId = BllCreditNoteMaster.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(); DebitNoteBll bll = new DebitNoteBll(); decimal decMasterId = bll.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> /// To reset the form here and Generate the voucher no generation /// </summary> public void Clear() { try { TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll(); if (btnSave.Text == "Update") { if (frmPaymentRegisterObj != null) { frmPaymentRegisterObj.Close(); } } if (isAutomatic) { SalaryVoucherBll BllSalaryVoucher = new SalaryVoucherBll(); //PaymentMasterSP SpPaymentMaster = new PaymentMasterSP(); PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll(); if (strVoucherNo == string.Empty) { strVoucherNo = "0"; } strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName); if (Convert.ToDecimal(strVoucherNo) != BllPaymentVoucher.PaymentMasterMax(decPaymentVoucherTypeId) + 1) { strVoucherNo = BllPaymentVoucher.PaymentMasterMax(decPaymentVoucherTypeId).ToString(); strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName); if (BllPaymentVoucher.PaymentMasterMax(decPaymentVoucherTypeId) == 0) { strVoucherNo = "0"; strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName); } } SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll(); SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo(); infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPaymentVoucherTypeId, dtpDate.Value); strPrefix = infoSuffixPrefix.Prefix; strSuffix = infoSuffixPrefix.Suffix; strInvoiceNo = strPrefix + strVoucherNo + strSuffix; txtVoucherNo.Text = strInvoiceNo; txtVoucherNo.ReadOnly = true; } else { txtVoucherNo.Text = string.Empty; txtVoucherNo.ReadOnly = false; } dtpDate.MinDate = PublicVariables._dtFromDate; dtpDate.MaxDate = PublicVariables._dtToDate; dtpDate.Value = PublicVariables._dtCurrentDate; cmbBankorCash.SelectedIndex = -1; txtNarration.Text = string.Empty; txtTotal.Text = string.Empty; dgvPaymentVoucher.ClearSelection(); dgvPaymentVoucher.Rows.Clear(); btnSave.Text = "Save"; btnDelete.Enabled = false; cbxPrintafterSave.Checked = false; dtblPartyBalance.Clear(); if (isAutomatic) { txtDate.Select(); } else { txtVoucherNo.Select(); } PrintCheck(); } catch (Exception ex) { MessageBox.Show("PV9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Delete Function /// </summary> /// <param name="decMasterId"></param> public void Delete(decimal decMasterId) { try { //PaymentMasterSP SpPaymentMaster = new PaymentMasterSP(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll(); if (!BllPartyBalance.PartyBalanceCheckReference(decPaymentVoucherTypeId, strVoucherNo)) { BllPaymentVoucher.PaymentVoucherDelete(decPaymentmasterId, decPaymentVoucherTypeId, strVoucherNo); Messages.DeletedMessage(); if (frmPaymentRegisterObj != null) { this.Close(); frmPaymentRegisterObj.CallFromPaymentVoucher(this); } else if (frmPaymentReportObj != null) { this.Close(); frmPaymentReportObj.CallFromPaymentVoucher(this); } else if (frmLedgerDetailsObj != null) { this.Close(); } if (_frmVoucherSearch != null) { this.Close(); _frmVoucherSearch.GridFill(); } if (frmDayBookObj != null) { this.Close(); } if (frmBillallocationObj != null) { this.Close(); } } else { Messages.InformationMessage("Reference exist. Cannot delete"); txtDate.Focus(); } } catch (Exception ex) { MessageBox.Show("PV19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save Function /// </summary> public void Save() { try { int inGridRowCount = dgvPaymentVoucher.RowCount; int inTableRowCount = dtblPartyBalance.Rows.Count; int inB = 0; PaymentMasterInfo InfoPaymentMaster = new PaymentMasterInfo(); //PaymentMasterSP SpPaymentMaster = new PaymentMasterSP(); PaymentDetailsInfo InfoPaymentDetails = new PaymentDetailsInfo(); //PaymentDetailsSP SpPaymentDetails = new PaymentDetailsSP(); PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); DateValidation objVal = new DateValidation(); TextBox txtDate1 = new TextBox(); InfoPaymentMaster.Date = dtpDate.Value; InfoPaymentMaster.Extra1 = string.Empty; InfoPaymentMaster.Extra2 = string.Empty; InfoPaymentMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoPaymentMaster.InvoiceNo = txtVoucherNo.Text.Trim(); ; InfoPaymentMaster.LedgerId = Convert.ToDecimal(cmbBankorCash.SelectedValue.ToString()); InfoPaymentMaster.Narration = txtNarration.Text.Trim(); InfoPaymentMaster.SuffixPrefixId = decDailySuffixPrefixId; decimal decTotalAmount = TotalAmountCalculation(); InfoPaymentMaster.TotalAmount = decTotalAmount; InfoPaymentMaster.UserId = PublicVariables._decCurrentUserId; InfoPaymentMaster.VoucherNo = strVoucherNo; InfoPaymentMaster.VoucherTypeId = decPaymentVoucherTypeId; decimal decPaymentMasterId = BllPaymentVoucher.PaymentMasterAdd(InfoPaymentMaster); if (decPaymentMasterId != 0) { MasterLedgerPosting(); } for (int inI = 0; inI < inGridRowCount - 1; inI++) { if (dgvPaymentVoucher.Rows[inI].HeaderCell.Value.ToString() != "X") { InfoPaymentDetails.Amount = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); InfoPaymentDetails.ExchangeRateId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()); InfoPaymentDetails.Extra1 = string.Empty; InfoPaymentDetails.Extra2 = string.Empty; InfoPaymentDetails.LedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); InfoPaymentDetails.PaymentMasterId = decPaymentMasterId; if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { InfoPaymentDetails.LedgerId = Convert.ToDecimal(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); } if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { InfoPaymentDetails.ChequeNo = dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString(); if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty) { InfoPaymentDetails.ChequeDate = Convert.ToDateTime(dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value); } else { InfoPaymentDetails.ChequeDate = DateTime.Now; } } else { InfoPaymentDetails.ChequeNo = string.Empty; InfoPaymentDetails.ChequeDate = DateTime.Now; } decimal decPaymentDetailsId = BllPaymentVoucher.PaymentDetailsAdd(InfoPaymentDetails); if (decPaymentDetailsId != 0) { for (int inJ = 0; inJ < inTableRowCount; inJ++) { if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString()) { PartyBalanceAddOrEdit(inJ); } } inB++; DetailsLedgerPosting(inI, decPaymentDetailsId); } } } Messages.SavedMessage(); if (cbxPrintafterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPaymentmasterId); } else { Print(decPaymentMasterId); } } Clear(); } catch (Exception ex) { MessageBox.Show("PV17:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save or edit function, checking invalid entries to save or update /// </summary> public void SaveOrEdit() { try { //PaymentMasterSP SpPaymentMaster = new PaymentMasterSP(); PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll(); int inIfGridColumnMissing = 0; int inRowCount = dgvPaymentVoucher.RowCount; ArrayList arrLst = new ArrayList(); string output = string.Empty; if (txtVoucherNo.Text == string.Empty) { Messages.InformationMessage("Enter voucher number."); txtVoucherNo.Focus(); inIfGridColumnMissing = 1; } else if (cmbBankorCash.SelectedIndex == -1) { Messages.InformationMessage("Select any bank or cash"); cmbBankorCash.Focus(); inIfGridColumnMissing = 1; } else if (inRowCount == 1) { Messages.InformationMessage("Can't save without atleast one complete details"); dgvPaymentVoucher.Focus(); inIfGridColumnMissing = 1; } else if (Convert.ToDecimal(txtTotal.Text) == 0) { Messages.InformationMessage("Can't save the total amount as Zero"); dgvPaymentVoucher.Focus(); } else { int inJ = 0; for (int inI = 0; inI < inRowCount - 1; inI++) { if (dgvPaymentVoucher.Rows[inI].HeaderCell.Value.ToString() == "X") { arrLst.Add(Convert.ToString(inI + 1)); inIfGridColumnMissing = 1; inJ++; } } if (inJ != 0) { if (inJ == inRowCount - 1) { Messages.InformationMessage("Can't save without atleat one complete details"); inIfGridColumnMissing = 1; } else { foreach (object obj in arrLst) { string str = Convert.ToString(obj); if (str != null) { output += str + ","; } else { break; } } bool isOk = Messages.UpdateMessageCustom("Row No " + output + " not completed.Do you want to continue?"); if (isOk) { inIfGridColumnMissing = 0; } else { inIfGridColumnMissing = 1; } } } if (inIfGridColumnMissing == 0) { if (btnSave.Text == "Save") { if (!isAutomatic) { if (BllPaymentVoucher.PaymentVoucherCheckExistence(txtVoucherNo.Text.Trim(), decPaymentVoucherTypeId, 0)) { Messages.InformationMessage("Voucher number already exist"); } else { if (PublicVariables.isMessageAdd) { if (Messages.SaveMessage()) { Save(); } } else { Save(); } } } else { if (PublicVariables.isMessageAdd) { if (Messages.SaveMessage()) { Save(); } } else { Save(); } } } else if (btnSave.Text == "Update") { if (!isAutomatic) { if (BllPaymentVoucher.PaymentVoucherCheckExistence(txtVoucherNo.Text.Trim(), decPaymentVoucherTypeId, decPaymentmasterId)) { Messages.InformationMessage("Voucher number already exist"); } else { if (PublicVariables.isMessageEdit) { if (Messages.UpdateMessage()) { Edit(decPaymentmasterId); } } else { Edit(decPaymentmasterId); } } } else { if (PublicVariables.isMessageEdit) { if (Messages.UpdateMessage()) { Edit(decPaymentmasterId); } } else { Edit(decPaymentmasterId); } } } } } } catch (Exception ex) { MessageBox.Show("PV14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Print function /// </summary> /// <param name="decPaymentMasterId"></param> public void Print(decimal decPaymentMasterId) { try { //PaymentMasterSP SpPaymentMaster = new PaymentMasterSP(); PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll(); DataSet dsPaymentVoucher = BllPaymentVoucher.PaymentVoucherPrinting(decPaymentMasterId, 1); frmReport frmReport = new frmReport(); frmReport.MdiParent = formMDI.MDIObj; frmReport.PaymentVoucherPrinting(dsPaymentVoucher); } catch (Exception ex) { MessageBox.Show("PV10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Grid Fill function while coming from other form to update or delete /// </summary> public void FillFunction() { try { //PaymentMasterSP SpPaymentMaster = new PaymentMasterSP(); PaymentMasterInfo InfoPaymentMaster = new PaymentMasterInfo(); //PaymentDetailsSP SpPaymentDetails = new PaymentDetailsSP(); PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); AccountGroupBll bllAccountGroup = new AccountGroupBll(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); InfoPaymentMaster = BllPaymentVoucher.PaymentMasterViewByMasterId(decPaymentmasterId);//view master details isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(InfoPaymentMaster.VoucherTypeId); if (isAutomatic) { txtVoucherNo.ReadOnly = true; txtVoucherNo.Text = InfoPaymentMaster.InvoiceNo; txtDate.Focus(); } else { txtVoucherNo.ReadOnly = false; txtVoucherNo.Text = InfoPaymentMaster.InvoiceNo; txtVoucherNo.Focus(); } dtpDate.Text = InfoPaymentMaster.Date.ToString(); cmbBankorCash.SelectedValue = InfoPaymentMaster.LedgerId; txtNarration.Text = InfoPaymentMaster.Narration; txtTotal.Text = InfoPaymentMaster.TotalAmount.ToString(); decDailySuffixPrefixId = InfoPaymentMaster.SuffixPrefixId; decPaymentVoucherTypeId = InfoPaymentMaster.VoucherTypeId; strVoucherNo = InfoPaymentMaster.VoucherNo; strInvoiceNo = InfoPaymentMaster.InvoiceNo; //DataTable dtbl = new DataTable(); List<DataTable> listObj1 = new List<DataTable>(); listObj1 = BllPaymentVoucher.PaymentDetailsViewByMasterId(decPaymentmasterId);//view details details for (int inI = 0; inI < listObj1[0].Rows.Count; inI++) { dgvPaymentVoucher.Rows.Add(); dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(listObj1[0].Rows[inI]["ledgerId"].ToString()); dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentMasterId"].Value = listObj1[0].Rows[inI]["paymentMasterId"].ToString(); dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].Value = listObj1[0].Rows[inI]["paymentDetailsId"].ToString(); dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].Value = listObj1[0].Rows[inI]["amount"].ToString(); dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(listObj1[0].Rows[inI]["exchangeRateId"].ToString()); decimal decDetailsId1 = Convert.ToDecimal(listObj1[0].Rows[inI]["paymentDetailsId"].ToString()); decimal decLedgerPostingId = BllLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decPaymentVoucherTypeId); dgvPaymentVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString(); decimal decLedgerId = Convert.ToDecimal(listObj1[0].Rows[inI]["ledgerId"].ToString()); bool IsBankAccount = bllAccountGroup.AccountGroupwithLedgerId(decLedgerId); decimal decI = Convert.ToDecimal(bllAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].FormattedValue.ToString())); if (decI > 0)//to make amount and currency read only when party is choosen as ledger { dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = true; dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = true; } else { dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = false; dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = false; } dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value = listObj1[0].Rows[inI]["ChequeNo"].ToString(); if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value = Convert.ToDateTime(listObj1[0].Rows[inI]["ChequeDate"].ToString()).ToString("dd-MMM-yyyy"); } dgvPaymentVoucher.Rows[inI].HeaderCell.Value = string.Empty; } List<DataTable> listObj = new List<DataTable>(); listObj = BllPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decPaymentVoucherTypeId, strVoucherNo, InfoPaymentMaster.Date); dtblPartyBalance = listObj[0]; } catch (Exception ex) { MessageBox.Show("PV36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill Datagridview /// </summary> public void gridfill() { try { PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll(); PaymentMasterInfo infoPaymentMaster = new PaymentMasterInfo(); List<DataTable> listObj = new List<DataTable>(); if (cmbAccountLedger.Items.Count > 0) { if (cmbAccountLedger.SelectedValue.ToString() != "System.Data.DataRowView") { if (txtFromDate.Text.Trim() != string.Empty && txtToDate.Text.Trim() != string.Empty) { listObj = BllPaymentVoucher.PaymentMasterSearch(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), Convert.ToDecimal(cmbAccountLedger.SelectedValue), txtVoucherNo.Text); dgvPaymentRegister.DataSource = listObj[0]; } } } } catch (Exception ex) { MessageBox.Show("PREG4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void Print() { try { PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll(); DataSet dsPaymentReport = BllPaymentVoucher.PaymentReportPrinting(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), Convert.ToDecimal(cmbLedger.SelectedValue), Convert.ToDecimal(cmbVoucherType.SelectedValue), Convert.ToDecimal(cmbBankOrCash.SelectedValue), 1); frmReport frmReport = new frmReport(); frmReport.MdiParent = formMDI.MDIObj; frmReport.PaymentReportPrinting(dsPaymentReport); } catch (Exception ex) { MessageBox.Show("PRP1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the grid based on the search catogeries /// </summary> public void GridFill() { try { PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll(); List<DataTable> listObj = new List<DataTable>(); if (cmbLedger.Items.Count != 0 && cmbVoucherType.Items.Count != 0 && cmbBankOrCash.Items.Count != 0) { if ((cmbLedger.SelectedValue.ToString() != "System.Data.DataRowView") && (cmbVoucherType.SelectedValue.ToString() != "System.Data.DataRowView" ) && (cmbBankOrCash.SelectedValue.ToString() != "System.Data.DataRowView")) { if (txtFromDate.Text.Trim() != string.Empty && txtToDate.Text.Trim() != string.Empty) { listObj = BllPaymentVoucher.PaymentReportSearch(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), Convert.ToDecimal(cmbLedger.SelectedValue), Convert.ToDecimal(cmbVoucherType.SelectedValue), Convert.ToDecimal(cmbBankOrCash.SelectedValue)); dgvPaymentReport.DataSource = listObj[0]; } } } } catch (Exception ex) { MessageBox.Show("PRP5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }