/// <summary> /// Function to print the details /// </summary> public void Print() { try { ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); DataSet dsReceiptReport = SpReceiptMaster.ReceiptReportPrinting(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), Convert.ToDecimal(cmbLedger.SelectedValue), Convert.ToDecimal(cmbVoucherType.SelectedValue), Convert.ToDecimal(cmbCashOrBank.SelectedValue), 1); frmReport frmReport = new frmReport(); frmReport.MdiParent = formMDI.MDIObj; frmReport.ReceiptReportPrinting(dsReceiptReport); } catch (Exception ex) { MessageBox.Show("RRP1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to print the details /// </summary> public void Print() { try { ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); DataSet dsReceiptReport = SpReceiptMaster.ReceiptReportPrinting(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), Convert.ToDecimal(cmbLedger.SelectedValue), Convert.ToDecimal(cmbVoucherType.SelectedValue), Convert.ToDecimal(cmbCashOrBank.SelectedValue), 1); frmReport frmReport = new frmReport(); frmReport.MdiParent = formMDI.MDIObj; frmReport.ReceiptReportPrinting(dsReceiptReport); } catch (Exception ex) { formMDI.infoError.ErrorString = "RRP1:" + ex.Message; } }
/// <summary> /// Function to fill datagridview /// </summary> public void gridfill() { try { ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); ReceiptMasterInfo InfoReceiptMaster = new ReceiptMasterInfo(); DataTable dtbl = new DataTable(); if (cmbAccountLedger.SelectedValue.ToString() != "System.Data.DataRowView") { if (txtFromDate.Text.Trim() != string.Empty && txtToDate.Text.Trim() != string.Empty) { dtbl = SpReceiptMaster.ReceiptMasterSearch(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), Convert.ToDecimal(cmbAccountLedger.SelectedValue), txtVoucherNo.Text); dgvReceiptRegister.DataSource = dtbl; } } } catch (Exception ex) { formMDI.infoError.ErrorString = "RR4:" + ex.Message; } }
/// <summary> /// Function to fill datagridview /// </summary> public void gridfill() { try { ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); ReceiptMasterInfo InfoReceiptMaster = new ReceiptMasterInfo(); DataTable dtbl = new DataTable(); if (cmbAccountLedger.SelectedValue.ToString() != "System.Data.DataRowView") { if (txtFromDate.Text.Trim() != string.Empty && txtToDate.Text.Trim() != string.Empty) { dtbl = SpReceiptMaster.ReceiptMasterSearch(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), Convert.ToDecimal(cmbAccountLedger.SelectedValue), txtVoucherNo.Text); dgvReceiptRegister.DataSource = dtbl; } } } catch (Exception ex) { MessageBox.Show("RR4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the grid based on the Search condition /// </summary> public void GridFill() { try { ReceiptMasterSP SpPaymentMaster = new ReceiptMasterSP(); DataTable dtbl = new DataTable(); if (cmbLedger.Items.Count != 0 && cmbVoucherType.Items.Count != 0 && cmbCashOrBank.Items.Count != 0) { if ((cmbLedger.SelectedValue.ToString() != "System.Data.DataRowView") && (cmbVoucherType.SelectedValue.ToString() != "System.Data.DataRowView") && (cmbCashOrBank.SelectedValue.ToString() != "System.Data.DataRowView")) { if (txtFromDate.Text.Trim() != string.Empty && txtToDate.Text.Trim() != string.Empty) { dtbl = SpPaymentMaster.ReceiptReportSearch(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), Convert.ToDecimal(cmbLedger.SelectedValue), Convert.ToDecimal(cmbVoucherType.SelectedValue), Convert.ToDecimal(cmbCashOrBank.SelectedValue)); dgvReceiptReport.DataSource = dtbl; } } } } catch (Exception ex) { formMDI.infoError.ErrorString = "RRP5:" + ex.Message; } }
/// <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> /// Function to fill the grid based on the Search condition /// </summary> public void GridFill() { try { ReceiptMasterSP SpPaymentMaster = new ReceiptMasterSP(); DataTable dtbl = new DataTable(); if (cmbLedger.Items.Count != 0 && cmbVoucherType.Items.Count != 0 && cmbCashOrBank.Items.Count != 0) { if ((cmbLedger.SelectedValue.ToString() != "System.Data.DataRowView") && (cmbVoucherType.SelectedValue.ToString() != "System.Data.DataRowView") && (cmbCashOrBank.SelectedValue.ToString() != "System.Data.DataRowView")) { if (txtFromDate.Text.Trim() != string.Empty && txtToDate.Text.Trim() != string.Empty) { dtbl = SpPaymentMaster.ReceiptReportSearch(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), Convert.ToDecimal(cmbLedger.SelectedValue), Convert.ToDecimal(cmbVoucherType.SelectedValue), Convert.ToDecimal(cmbCashOrBank.SelectedValue)); dgvReceiptReport.DataSource = dtbl; } } } } catch (Exception ex) { MessageBox.Show("RRP5:" + 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> /// Fill function for updation /// </summary> public void FillFunction() { try { isValueChange = false; ReceiptMasterInfo InfoReceiptMaster = new ReceiptMasterInfo(); ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); ReceiptDetailsInfo InfoReceiptDetails = new ReceiptDetailsInfo(); ReceiptDetailsSP SpReceiptDetails = new ReceiptDetailsSP(); PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); LedgerPostingSP SpLedgerPosting = new LedgerPostingSP(); VoucherTypeSP SpVoucherType = new VoucherTypeSP(); AccountGroupSP spAccountGroup = new AccountGroupSP(); AccountLedgerSP SpAccountLedger = new AccountLedgerSP(); InfoReceiptMaster = SpReceiptMaster.ReceiptMasterViewByMasterId(decRecieptmasterId); isAutomatic = SpVoucherType.CheckMethodOfVoucherNumbering(InfoReceiptMaster.VoucherTypeId); if (isAutomatic) { txtVoucherNo.ReadOnly = true; txtVoucherNo.Text = InfoReceiptMaster.InvoiceNo; } else { txtVoucherNo.ReadOnly = false; txtVoucherNo.Text = InfoReceiptMaster.VoucherNo; } dtpDate.Value = InfoReceiptMaster.Date; cmbCashOrBank.SelectedValue = InfoReceiptMaster.LedgerId; txtNarration.Text = InfoReceiptMaster.Narration; txtTotal.Text = InfoReceiptMaster.TotalAmount.ToString(); decDailySuffixPrefixId = InfoReceiptMaster.SuffixPrefixId; decReceiptVoucherTypeId = InfoReceiptMaster.VoucherTypeId; strVoucherNo = InfoReceiptMaster.VoucherNo; strInvoiceNo = InfoReceiptMaster.InvoiceNo; DataTable dtbl = new DataTable(); dtbl = SpReceiptDetails.ReceiptDetailsViewByMasterId(decRecieptmasterId); for (int inI = 0; inI < dtbl.Rows.Count; inI++) { dgvReceiptVoucher.Rows.Add(); dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(dtbl.Rows[inI]["ledgerId"].ToString()); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtreceiptMasterId"].Value = dtbl.Rows[inI]["receiptMasterId"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtreceiptDetailsId"].Value = dtbl.Rows[inI]["receiptDetailsId"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].Value = dtbl.Rows[inI]["amount"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(dtbl.Rows[inI]["exchangeRateId"].ToString()); decimal decDetailsId1 = Convert.ToDecimal(dtbl.Rows[inI]["receiptDetailsId"].ToString()); decimal decLedgerPostingId = SpLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decReceiptVoucherTypeId); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString(); decimal decLedgerId = Convert.ToDecimal(dtbl.Rows[inI]["ledgerId"].ToString()); bool IsBankAccount = spAccountGroup.AccountGroupwithLedgerId(decLedgerId); decimal decI = Convert.ToDecimal(SpAccountLedger.AccountGroupIdCheck(dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].FormattedValue.ToString())); if (decI > 0) { dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = true; dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = true; } else { dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = false; dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = false; } if (dtbl.Rows[inI]["chequeNo"].ToString() != string.Empty) { dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value = dtbl.Rows[inI]["chequeNo"].ToString(); dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value = Convert.ToDateTime(dtbl.Rows[inI]["chequeDate"].ToString()).ToString("dd-MMM-yyyy"); } dgvReceiptVoucher.Rows[inI].HeaderCell.Value = string.Empty; } DataTable dtbl1 = new DataTable(); dtbl1 = SpPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decReceiptVoucherTypeId, strVoucherNo, InfoReceiptMaster.Date); dtblPartyBalance = dtbl1; isValueChange = true; } catch (Exception ex) { MessageBox.Show("RV34:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Clear function /// </summary> public void Clear() { try { TransactionsGeneralFill obj = new TransactionsGeneralFill(); if (btnSave.Text == "Update") { if (frmReceiptRegisterObj != null) { frmReceiptRegisterObj.Close(); } } if (isAutomatic == true) { SalaryVoucherMasterSP spMaster = new SalaryVoucherMasterSP(); ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); if (strVoucherNo == string.Empty) { strVoucherNo = "0"; } strVoucherNo = obj.VoucherNumberAutomaicGeneration(decReceiptVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName); if (Convert.ToDecimal(strVoucherNo) != SpReceiptMaster.ReceiptMasterGetMax(decReceiptVoucherTypeId) + 1) { strVoucherNo = SpReceiptMaster.ReceiptMasterGetMax(decReceiptVoucherTypeId).ToString(); strVoucherNo = obj.VoucherNumberAutomaicGeneration(decReceiptVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName); if (SpReceiptMaster.ReceiptMasterGetMax(decReceiptVoucherTypeId) == 0) { strVoucherNo = "0"; strVoucherNo = obj.VoucherNumberAutomaicGeneration(decReceiptVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName); } } SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP(); SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo(); infoSuffixPrefix = spSuffisprefix.GetSuffixPrefixDetails(decReceiptVoucherTypeId, 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; cmbCashOrBank.SelectedIndex = -1; txtNarration.Text = string.Empty; txtTotal.Text = string.Empty; dgvReceiptVoucher.ClearSelection(); dgvReceiptVoucher.Rows.Clear(); btnDelete.Enabled = false; btnSave.Text = "Save"; cbxPrintafterSave.Checked = false; dtblPartyBalance.Clear(); if (isAutomatic) { txtDate.Select(); } else { txtVoucherNo.Focus(); } SettingsSP spSettings = new SettingsSP(); if (spSettings.SettingsStatusCheck("TickPrintAfterSave") == "Yes") { cbxPrintafterSave.Checked = true; } else { cbxPrintafterSave.Checked = false; } } catch (Exception ex) { MessageBox.Show("RV6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Delete Function /// </summary> /// <param name="decMasterId"></param> public void Delete(decimal decMasterId) { try { ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); if (!SpPartyBalance.PartyBalanceCheckReference(decReceiptVoucherTypeId, strVoucherNo)) { SpReceiptMaster.ReceiptVoucherDelete(decRecieptmasterId, decReceiptVoucherTypeId, strVoucherNo); Messages.DeletedMessage(); if (frmReceiptRegisterObj != null) { this.Close(); frmReceiptRegisterObj.CallFromReceiptVoucher(this); } else if (frmReceiptReportObj != null) { this.Close(); frmReceiptReportObj.CallFromReceiptVoucher(this); } else if (frmLedgerDetailsObj != null) { this.Close(); } else 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("RV5:" + 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> /// Print function /// </summary> /// <param name="decReceiptMasterId"></param> public void Print(decimal decReceiptMasterId) { try { ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); DataSet dsReceiptVoucher = SpReceiptMaster.ReceiptVoucherPrinting(decReceiptMasterId);// PublicVariables._decCurrentCompanyId); frmReport frmReport = new frmReport(); frmReport.MdiParent = formMDI.MDIObj; frmReport.ReceiptVoucherPrinting(dsReceiptVoucher); } catch (Exception ex) { MessageBox.Show("Rv14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Edit function /// </summary> /// <param name="decMasterId"></param> public void Edit(decimal decMasterId) { try { int inRowCount = dgvReceiptVoucher.RowCount; int inTableRowCount = dtblPartyBalance.Rows.Count; int inB = 0; ReceiptMasterInfo InfoReceiptMaster = new ReceiptMasterInfo(); ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); ReceiptDetailsInfo InfoReceiptDetails = new ReceiptDetailsInfo(); ReceiptDetailsSP SpReceiptDetails = new ReceiptDetailsSP(); LedgerPostingSP SpLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo InfoLegerPosting = new LedgerPostingInfo(); PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); BankReconciliationSP SpBankReconcilation = new BankReconciliationSP(); InfoReceiptMaster.Date = dtpDate.Value; InfoReceiptMaster.ReceiptMasterId = decMasterId; InfoReceiptMaster.Extra1 = string.Empty; InfoReceiptMaster.Extra2 = string.Empty; InfoReceiptMaster.ExtraDate = DateTime.Now; InfoReceiptMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoReceiptMaster.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString()); InfoReceiptMaster.Narration = txtNarration.Text.Trim(); decimal decTotalAmount = TotalAmountCalculation(); InfoReceiptMaster.TotalAmount = decTotalAmount; InfoReceiptMaster.UserId = PublicVariables._decCurrentUserId; if (!isAutomatic) { InfoReceiptMaster.VoucherNo = txtVoucherNo.Text.Trim(); InfoReceiptMaster.InvoiceNo = txtVoucherNo.Text.Trim(); InfoReceiptMaster.SuffixPrefixId = 0; } else { InfoReceiptMaster.VoucherNo = strVoucherNo; InfoReceiptMaster.InvoiceNo = strInvoiceNo; InfoReceiptMaster.SuffixPrefixId = decDailySuffixPrefixId; } InfoReceiptMaster.VoucherTypeId = decReceiptVoucherTypeId; decimal decEffectRow = SpReceiptMaster.ReceiptMasterEdit(InfoReceiptMaster); if (decEffectRow != 0) { MasterLedgerPostingEdit(); } foreach (object obj in arrlstOfRemove) { string str = Convert.ToString(obj); SpReceiptDetails.ReceiptDetailsDelete(Convert.ToDecimal(str)); SpLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(str), strVoucherNo, decReceiptVoucherTypeId); } decimal decReceiptDetailsId1 = 0; SpLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decReceiptVoucherTypeId, 12); for (int inI = 0; inI < inRowCount - 1; inI++) { InfoReceiptDetails.Amount = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); InfoReceiptDetails.ExchangeRateId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()); InfoReceiptDetails.Extra1 = string.Empty; InfoReceiptDetails.Extra2 = string.Empty; InfoReceiptDetails.ReceiptMasterId = InfoReceiptMaster.ReceiptMasterId; if (dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { InfoReceiptDetails.LedgerId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); } if (dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { InfoReceiptDetails.ChequeNo = dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString(); if (dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty) { InfoReceiptDetails.ChequeDate = Convert.ToDateTime(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value); } else { InfoReceiptDetails.ChequeDate = DateTime.Now; } } else { InfoReceiptDetails.ChequeNo = string.Empty; InfoReceiptDetails.ChequeDate = DateTime.Now; } if (dgvReceiptVoucher.Rows[inI].Cells["dgvtxtReceiptDetailsId"].Value == null || dgvReceiptVoucher.Rows[inI].Cells["dgvtxtReceiptDetailsId"].Value.ToString() == string.Empty)//if new rows are added { if (dgvReceiptVoucher.Rows[inI].HeaderCell.Value.ToString() != "X") { decimal decReceiptDetailsId = SpReceiptDetails.ReceiptDetailsAdd(InfoReceiptDetails); if (decReceiptDetailsId != 0) { for (int inJ = 0; inJ < inTableRowCount; inJ++) { if (dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString()) { PartyBalanceAddOrEdit(inJ); } } inB++; DetailsLedgerPosting(inI, decReceiptDetailsId); } } } else { if (dgvReceiptVoucher.Rows[inI].HeaderCell.Value.ToString() != "X") { InfoReceiptDetails.ReceiptDetailsId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtreceiptDetailsId"].Value.ToString()); decimal decReceiptDetailsId = SpReceiptDetails.ReceiptDetailsEdit(InfoReceiptDetails); if (decReceiptDetailsId != 0) { for (int inJ = 0; inJ < inTableRowCount; inJ++) { if (dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString()) { PartyBalanceAddOrEdit(inJ); } } inB++; decReceiptDetailsId = InfoReceiptDetails.ReceiptDetailsId; decimal decLedgerPostId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value.ToString()); DetailsLedgerPostingEdit(inI, decLedgerPostId, decReceiptDetailsId1); } } else { decimal decDetailsId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtreceiptDetailsId"].Value.ToString()); SpReceiptDetails.ReceiptDetailsDelete(decDetailsId); SpLedgerPosting.LedgerPostDeleteByDetailsId(decDetailsId, strVoucherNo, decReceiptVoucherTypeId); for (int inJ = 0; inJ < dtblPartyBalance.Rows.Count; inJ++) { if (dtblPartyBalance.Rows.Count == inJ) { break; } if (dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { if (dtblPartyBalance.Rows[inJ]["LedgerId"].ToString() == dgvReceiptVoucher.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 (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(InfoReceiptMaster.ReceiptMasterId); } else { Print(InfoReceiptMaster.ReceiptMasterId); } } if (frmReceiptRegisterObj != null) { this.Close(); frmReceiptRegisterObj.CallFromReceiptVoucher(this); } if (frmReceiptReportObj != null) { this.Close(); frmReceiptReportObj.CallFromReceiptVoucher(this); } if (frmDayBookObj != null) { this.Close(); } if (frmBillallocationObj != null) { this.Close(); } } catch (Exception ex) { MessageBox.Show("RV13:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save function /// </summary> public void Save() { try { int inGridRowCount = dgvReceiptVoucher.RowCount; int inTableRowCount = dtblPartyBalance.Rows.Count; int inB = 0; ReceiptMasterInfo InfoReceiptMaster = new ReceiptMasterInfo(); ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); ReceiptDetailsInfo InfoReceiptDetails = new ReceiptDetailsInfo(); ReceiptDetailsSP SpReceiptDetails = new ReceiptDetailsSP(); PartyBalanceSP SpPartyBalance = new PartyBalanceSP(); PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo(); InfoReceiptMaster.Date = dtpDate.Value; InfoReceiptMaster.Extra1 = string.Empty; InfoReceiptMaster.Extra2 = string.Empty; InfoReceiptMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoReceiptMaster.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString()); InfoReceiptMaster.Narration = txtNarration.Text; decimal decTotalAmount = TotalAmountCalculation(); InfoReceiptMaster.TotalAmount = decTotalAmount; InfoReceiptMaster.UserId = PublicVariables._decCurrentUserId; if (!isAutomatic) { InfoReceiptMaster.VoucherNo = txtVoucherNo.Text.Trim(); InfoReceiptMaster.InvoiceNo = txtVoucherNo.Text.Trim(); InfoReceiptMaster.SuffixPrefixId = 0; } else { InfoReceiptMaster.VoucherNo = strVoucherNo; InfoReceiptMaster.InvoiceNo = strInvoiceNo; InfoReceiptMaster.SuffixPrefixId = decDailySuffixPrefixId; } InfoReceiptMaster.VoucherTypeId = decReceiptVoucherTypeId; decimal decReceiptMasterId = SpReceiptMaster.ReceiptMasterAdd(InfoReceiptMaster); if (decReceiptMasterId != 0) { MasterLedgerPosting(); } for (int inI = 0; inI < inGridRowCount - 1; inI++) { if (dgvReceiptVoucher.Rows[inI].HeaderCell.Value.ToString() != "X") { InfoReceiptDetails.Amount = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); InfoReceiptDetails.ExchangeRateId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()); InfoReceiptDetails.Extra1 = string.Empty; InfoReceiptDetails.Extra2 = string.Empty; InfoReceiptDetails.LedgerId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); InfoReceiptDetails.ReceiptMasterId = decReceiptMasterId; if (dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty) { InfoReceiptDetails.LedgerId = Convert.ToDecimal(dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString()); } if (dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty) { InfoReceiptDetails.ChequeNo = dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString(); if (dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty) { InfoReceiptDetails.ChequeDate = Convert.ToDateTime(dgvReceiptVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value); } else { InfoReceiptDetails.ChequeDate = DateTime.Now; } } else { InfoReceiptDetails.ChequeNo = string.Empty; InfoReceiptDetails.ChequeDate = DateTime.Now; } decimal decReceiptDetailsId = SpReceiptDetails.ReceiptDetailsAdd(InfoReceiptDetails); if (decReceiptDetailsId != 0) { for (int inJ = 0; inJ < inTableRowCount; inJ++) { if (dgvReceiptVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() == dtblPartyBalance.Rows[inJ]["LedgerId"].ToString()) { PartyBalanceAddOrEdit(inJ); } } inB++; DetailsLedgerPosting(inI, decReceiptDetailsId); } } } Messages.SavedMessage(); if (cbxPrintafterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decReceiptMasterId); } else { Print(decReceiptMasterId); } } Clear(); } catch (Exception ex) { MessageBox.Show("RV12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save or edit function and checking the invalid entries /// </summary> public void SaveOrEdit() { try { ReceiptMasterSP SpReceiptMaster = new ReceiptMasterSP(); int inIfGridColumnMissing = 0; int inRowCount = dgvReceiptVoucher.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 (cmbCashOrBank.SelectedIndex == -1) { Messages.InformationMessage("Select any bank or cash."); cmbCashOrBank.Focus(); inIfGridColumnMissing = 1; } else if (inRowCount == 1) { Messages.InformationMessage("Can't save without atleat one complete details"); dgvReceiptVoucher.Focus(); inIfGridColumnMissing = 1; } else if (Convert.ToDecimal(txtTotal.Text) == 0) { Messages.InformationMessage("Can't save total amount as Zero"); dgvReceiptVoucher.Focus(); } else { int inJ = 0; for (int inI = 0; inI < inRowCount - 1; inI++) { if (dgvReceiptVoucher.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 == true) { inIfGridColumnMissing = 0; } else { inIfGridColumnMissing = 1; } } } if (inIfGridColumnMissing == 0) { if (btnSave.Text == "Save") { if (!isAutomatic) { if (SpReceiptMaster.ReceiptVoucherCheckExistence(txtVoucherNo.Text.Trim(), decReceiptVoucherTypeId, 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 (SpReceiptMaster.ReceiptVoucherCheckExistence(txtVoucherNo.Text.Trim(), decReceiptVoucherTypeId, decRecieptmasterId)) { Messages.InformationMessage("Voucher number already exist"); txtVoucherNo.Focus(); } else { if (PublicVariables.isMessageEdit) { if (Messages.UpdateMessage()) { Edit(decRecieptmasterId); } } else { Edit(decRecieptmasterId); } } } else { if (PublicVariables.isMessageEdit) { if (Messages.UpdateMessage()) { Edit(decRecieptmasterId); } } else { Edit(decRecieptmasterId); } } } } } } catch (Exception ex) { MessageBox.Show("RV27:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }