/// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void SearchRegister()
 {
     try
     {
         string strVoucherNo = txtVoucherNo.Text;
         string strToDate = string.Empty;
         string strFromDate = string.Empty;
         if (txtToDate.Text == string.Empty)
         {
             strToDate = txtFromDate.Text;
         }
         else
         {
             strToDate = txtToDate.Text;
         }
         if (txtFromDate.Text == string.Empty)
         {
             strFromDate = DateTime.Now.ToString();
         }
         else
         {
             strFromDate = txtFromDate.Text;
         }
         DataTable dtbl = new DataTable();
         CreditNoteMasterSP spCreditNoteMasterSp = new CreditNoteMasterSP();
         dtbl = spCreditNoteMasterSp.CreditNoteRegisterSearch(strVoucherNo, strFromDate, strToDate);
         dgvCreditNoteRegister.DataSource = dtbl;
     }
     catch (Exception ex)
     {
         MessageBox.Show("CRNTREG1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void SearchRegister()
 {
     try
     {
         string strVoucherNo = txtVoucherNo.Text;
         string strToDate    = string.Empty;
         string strFromDate  = string.Empty;
         if (txtToDate.Text == string.Empty)
         {
             strToDate = txtFromDate.Text;
         }
         else
         {
             strToDate = txtToDate.Text;
         }
         if (txtFromDate.Text == string.Empty)
         {
             strFromDate = DateTime.Now.ToString();
         }
         else
         {
             strFromDate = txtFromDate.Text;
         }
         DataTable          dtbl = new DataTable();
         CreditNoteMasterSP spCreditNoteMasterSp = new CreditNoteMasterSP();
         dtbl = spCreditNoteMasterSp.CreditNoteRegisterSearch(strVoucherNo, strFromDate, strToDate);
         dgvCreditNoteRegister.DataSource = dtbl;
     }
     catch (Exception ex)
     {
         MessageBox.Show("CRNTREG1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void SearchRegister()
 {
     try
     {
         string strVoucherNo = txtVoucherNo.Text;
         string strToDate    = string.Empty;
         string strFromDate  = string.Empty;
         if (txtToDate.Text == string.Empty)
         {
             strToDate = txtFromDate.Text;
         }
         else
         {
             strToDate = txtToDate.Text;
         }
         if (txtFromDate.Text == string.Empty)
         {
             strFromDate = DateTime.Now.ToString();
         }
         else
         {
             strFromDate = txtFromDate.Text;
         }
         DataTable          dtbl = new DataTable();
         CreditNoteMasterSP spCreditNoteMasterSp = new CreditNoteMasterSP();
         dtbl = spCreditNoteMasterSp.CreditNoteRegisterSearch(strVoucherNo, strFromDate, strToDate);
         dgvCreditNoteRegister.DataSource = dtbl;
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "CRNTREG1:" + ex.Message;
     }
 }
Exemple #4
0
        /// <summary>
        /// Function to 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          dtblCreditNoteReport = new DataTable();
                            CreditNoteMasterSP spCreditNoteMaster   = new CreditNoteMasterSP();
                            dtblCreditNoteReport           = spCreditNoteMaster.CreditNoteReportSearch(strFromDate, strToDate, decVoucherTypeId, decLedgerId);
                            dgvCreditNoteReport.DataSource = dtblCreditNoteReport;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "CRNTREP5:" + ex.Message;
            }
        }
        /// <summary>
        /// Function to print the Report
        /// </summary>
        public void Print()
        {
            try
            {
                string  strFromDate      = txtFromDate.Text;
                string  strToDate        = txtToDate.Text;
                decimal decVoucherTypeId = Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString());
                decimal decLedgerId      = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString());

                CreditNoteMasterSP SpCreditNoteMaster = new CreditNoteMasterSP();
                DataSet            dsCreditNoteReport = SpCreditNoteMaster.CreditNoteReportPrinting(strFromDate, strToDate, decVoucherTypeId, decLedgerId, 1);
                frmReport          frmReport          = new frmReport();
                frmReport.MdiParent = formMDI.MDIObj;
                frmReport.CreditNoteReportPrinting(dsCreditNoteReport);
            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNTREP6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #6
0
        /// <summary>
        /// Function to print the Report
        /// </summary>
        public void Print()
        {
            try
            {
                string  strFromDate      = txtFromDate.Text;
                string  strToDate        = txtToDate.Text;
                decimal decVoucherTypeId = Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString());
                decimal decLedgerId      = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString());

                CreditNoteMasterSP SpCreditNoteMaster = new CreditNoteMasterSP();
                DataSet            dsCreditNoteReport = SpCreditNoteMaster.CreditNoteReportPrinting(strFromDate, strToDate, decVoucherTypeId, decLedgerId, 1);
                frmReport          frmReport          = new frmReport();
                frmReport.MdiParent = formMDI.MDIObj;
                frmReport.CreditNoteReportPrinting(dsCreditNoteReport);
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "CRNTREP6:" + ex.Message;
            }
        }
 /// <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>
        /// 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);
            }
        }
Exemple #9
0
        /// <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;
            }
        }
Exemple #10
0
        /// <summary>
        /// Function to determine whether to call savefunction or edit function
        /// </summary>
        public void SaveOrEditFunction()
        {
            try
            {
                CreditNoteMasterSP spCreditNoteMaster = new CreditNoteMasterSP();
               
                    if (!isEditMode)
                    {
                        if (txtVoucherNo.Text.Trim() != string.Empty)
                        {

                            if (!isAutomatic)
                            {
                                strInvoiceNo = txtVoucherNo.Text.Trim();
                                if (spCreditNoteMaster.CreditNoteCheckExistence(strInvoiceNo, decCreditNoteVoucherTypeId, 0) == false)
                                {
                                    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 (spCreditNoteMaster.CreditNoteCheckExistence(strInvoiceNo, decCreditNoteVoucherTypeId, decCreditNoteMasterIdForEdit) == false)
                                {
                                    EditFunction(decCreditNoteMasterIdForEdit);
                                }
                                else
                                {
                                    Messages.InformationMessage("Voucher number already exist");
                                }
                            }
                            else
                            {
                                EditFunction(decCreditNoteMasterIdForEdit);
                            }
                        }
                        else
                        {
                            Messages.InformationMessage("Enter voucherNo");
                        }
                    }
                
            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNT:15" + 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>
        /// Function to 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 dtblCreditNoteReport = new DataTable();
                            CreditNoteMasterSP spCreditNoteMaster = new CreditNoteMasterSP();
                            dtblCreditNoteReport = spCreditNoteMaster.CreditNoteReportSearch(strFromDate, strToDate, decVoucherTypeId, decLedgerId);
                            dgvCreditNoteReport.DataSource = dtblCreditNoteReport;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNTREP5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #13
0
        /// <summary>
        /// Function to save the voucher
        /// </summary>
        public void Save()
        {
            try
            {
                decimal decTotalDebit = 0;
                decimal decTotalCredit = 0;

                decTotalDebit = Convert.ToDecimal(txtDebitTotal.Text.Trim());
                decTotalCredit = Convert.ToDecimal(txtCreditTotal.Text.Trim());

                CreditNoteMasterSP spCreditNoteMaster = new CreditNoteMasterSP();
                CreditNoteDetailsSP spCreditNoteDetails = new CreditNoteDetailsSP();
                CreditNoteMasterInfo infoCreditNoteMaster = new CreditNoteMasterInfo();
                CreditNoteDetailsInfo infoCreditNoteDetails = new CreditNoteDetailsInfo();
                PartyBalanceSP SpPartyBalance = new PartyBalanceSP();
                PartyBalanceInfo InfopartyBalance = new PartyBalanceInfo();
                ExchangeRateSP spExchangeRate = new ExchangeRateSP();

                infoCreditNoteMaster.VoucherNo = strVoucherNo;
                infoCreditNoteMaster.InvoiceNo = txtVoucherNo.Text.Trim();
                infoCreditNoteMaster.SuffixPrefixId = decCreditNoteSuffixPrefixId;
                infoCreditNoteMaster.Date = Convert.ToDateTime(txtDate.Text);
                infoCreditNoteMaster.Narration = txtNarration.Text.Trim();
                infoCreditNoteMaster.UserId = PublicVariables._decCurrentUserId;
                infoCreditNoteMaster.VoucherTypeId = decCreditNoteVoucherTypeId;
                infoCreditNoteMaster.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString());
                infoCreditNoteMaster.Extra1 = string.Empty;
                infoCreditNoteMaster.Extra2 = string.Empty;


                infoCreditNoteMaster.TotalAmount = decTotalDebit;
                decimal decCreditNoteMasterId = spCreditNoteMaster.CreditNoteMasterAdd(infoCreditNoteMaster);

                /*******************CreditNote Details Add and LedgerPosting*************************/
                infoCreditNoteDetails.CreditNoteMasterId = decCreditNoteMasterId;
                infoCreditNoteDetails.ExtraDate = DateTime.Now;
                infoCreditNoteDetails.Extra1 = string.Empty;
                infoCreditNoteDetails.Extra2 = string.Empty;

                decimal decLedgerId = 0;
                decimal decDebit = 0;
                decimal decCredit = 0;
                int inRowCount = dgvCreditNote.RowCount;
                for (int inI = 0; inI < inRowCount - 1; inI++)
                {
                    if (dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                    {
                        infoCreditNoteDetails.LedgerId = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString());
                        decLedgerId = infoCreditNoteDetails.LedgerId;
                    }
                    if (dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() != string.Empty)
                    {
                        if (dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString() != string.Empty)
                        {
                            //--------Currency conversion--------------//
                            decSelectedCurrencyRate = spExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString()));
                            decAmount = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                            decConvertRate = decAmount * decSelectedCurrencyRate;
                            //===========================================//
                            if (dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() == "Dr")
                            {
                                infoCreditNoteDetails.Debit = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                                infoCreditNoteDetails.Credit = 0;
                                decDebit = decConvertRate;
                                decCredit = infoCreditNoteDetails.Credit;
                            }
                            else
                            {
                                infoCreditNoteDetails.Credit = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                                infoCreditNoteDetails.Debit = 0;
                                decDebit = infoCreditNoteDetails.Debit;
                                decCredit = decConvertRate;
                            }
                        }
                        infoCreditNoteDetails.ExchangeRateId = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString());
                        if (dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                        {
                            infoCreditNoteDetails.ChequeNo = dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString();
                            if (dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                            {
                                infoCreditNoteDetails.ChequeDate = Convert.ToDateTime(dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value);
                            }
                            else
                            {
                                infoCreditNoteDetails.ChequeDate = DateTime.Now;
                            }
                        }
                        else
                        {
                            infoCreditNoteDetails.ChequeNo = string.Empty;
                            infoCreditNoteDetails.ChequeDate = DateTime.Now;
                        }
                        decimal decDetailsId = spCreditNoteDetails.CreditNoteDetailsAdd(infoCreditNoteDetails);

                        if (decDetailsId != 0)
                        {
                            PartyBalanceAddOrEdit(inI);
                            LedgerPosting(decLedgerId, decCredit, decDebit, decDetailsId, inI);
                        }
                    }

                }

                Messages.SavedMessage();


                //----------------If print after save is enable-----------------------//
                SettingsSP spSettings = new SettingsSP();
                if (cbxPrintAfterSave.Checked)
                {
                    if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                    {
                        PrintForDotMatrix(decCreditNoteMasterId);
                    }
                    else
                    {
                        Print(decCreditNoteMasterId);
                    }
                }

                //===================================================================//
            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNT:31" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
Exemple #14
0
 /// <summary>
 /// Function to delete a voucher
 /// </summary>
 /// <param name="decCreditNoteMasterId"></param>
 public void DeleteFunction(decimal decCreditNoteMasterId)
 {
     try
     {
         CreditNoteMasterSP spCreditNoteMaster = new CreditNoteMasterSP();
         PartyBalanceSP spPartyBalance = new PartyBalanceSP();
         if (!spPartyBalance.PartyBalanceCheckReference(decCreditNoteVoucherTypeId, strVoucherNo))
         {
             spCreditNoteMaster.CreditNoteVoucherDelete(decCreditNoteMasterId, decCreditNoteVoucherTypeId, strVoucherNo);
             Messages.DeletedMessage();
             if (CreditNoteRegisterObj != null)
             {
                 this.Close();
                 CreditNoteRegisterObj.Enabled = true;
             }
             else if (frmCreditNoteReportObj != null)
             {
                 this.Close();
                 frmCreditNoteReportObj.Enabled = true;
             }
             else  if (objVoucherSearch != null)
             {
                 this.Close();
                 objVoucherSearch.GridFill();
             }
             else if (frmDayBookObj != null)
             {
                 this.Close();
             }
             else if (frmBillallocationObj != null)
             {
                 this.Close();
             }
             else if (frmLedgerDetailsObj != null)
             {
                 this.Close();
             }
             else
             {
                 clear();
             }
         }
         else
         {
             Messages.InformationMessage("Reference exist. Cannot delete");
             txtDate.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("CRNT:24" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #15
0
 /// <summary>
 /// Function to print the voucher
 /// </summary>
 /// <param name="decMasterId"></param>
 public void Print(decimal decMasterId)
 {
     try
     {
         CreditNoteMasterSP spCreditNoteMaster = new CreditNoteMasterSP();
         DataSet dsCreditNote = spCreditNoteMaster.CreditNotePrinting(decMasterId, 1);
         frmReport frmReport = new frmReport();
         frmReport.MdiParent = formMDI.MDIObj;
         frmReport.CreditNotePrinting(dsCreditNote);
     }
     catch (Exception ex)
     {
         MessageBox.Show("CRNT:21" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #16
0
        /// <summary>
        /// Function to clear the fields
        /// </summary>
        public void clear()
        {
            try
            {
                TransactionsGeneralFill obj = new TransactionsGeneralFill();
                CreditNoteMasterSP spMaster = new CreditNoteMasterSP();

                //-----------------------------------VoucherNo automatic generation-------------------------------------------//

                if (strVoucherNo == string.Empty)
                {
                    strVoucherNo = "0"; //strMax;
                }
                strVoucherNo = obj.VoucherNumberAutomaicGeneration(decCreditNoteVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, strTableName);

                if (Convert.ToDecimal(strVoucherNo) != spMaster.CreditNoteMasterGetMaxPlusOne(decCreditNoteVoucherTypeId))
                {
                    strVoucherNo = spMaster.CreditNoteMasterGetMax(decCreditNoteVoucherTypeId).ToString();
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(decCreditNoteVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, strTableName);
                    if (spMaster.CreditNoteMasterGetMax(decCreditNoteVoucherTypeId).ToString() == "0")
                    {
                        strVoucherNo = "0";
                        strVoucherNo = obj.VoucherNumberAutomaicGeneration(decCreditNoteVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, strTableName);
                    }
                }

                //===================================================================================================================//
                if (isAutomatic)
                {
                    SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();

                    infoSuffixPrefix = spSuffisprefix.GetSuffixPrefixDetails(decCreditNoteVoucherTypeId, 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.Trim();
                }


                dgvCreditNote.Rows.Clear();
                VoucherDate();
                dtpVoucherDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                txtDebitTotal.Text = string.Empty;
                txtCreditTotal.Text = string.Empty;
                txtNarration.Text = string.Empty;
                btnSave.Text = "Save";
                btnDelete.Enabled = false;
                isEditMode = false;
                dtblPartyBalance.Clear();//to clear party balance entries to clear the dgvpatybalance
                PrintCheck();
                if (txtVoucherNo.ReadOnly != true)
                {
                    txtVoucherNo.Focus();
                }
                else
                {
                    txtDate.Select();
                }
                
            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNT:03" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #17
0
        /// <summary>
        /// Function to fill the controlls
        /// </summary>
        public void FillFunction()
        {
            try
            {
                CreditNoteMasterInfo infoCreditNoteMaster = new CreditNoteMasterInfo();
                CreditNoteMasterSP spCreditNoteMaster = new CreditNoteMasterSP();
                infoCreditNoteMaster = spCreditNoteMaster.CreditNoteMasterView(decCreditNoteMasterIdForEdit);

                txtVoucherNo.ReadOnly = false;
                strVoucherNo = infoCreditNoteMaster.VoucherNo;
                strInvoiceNo = infoCreditNoteMaster.InvoiceNo;
                txtVoucherNo.Text = strInvoiceNo;
                decCreditNoteSuffixPrefixId = infoCreditNoteMaster.SuffixPrefixId;
                decCreditNoteVoucherTypeId = infoCreditNoteMaster.VoucherTypeId;
                dtpVoucherDate.Value = infoCreditNoteMaster.Date;

                VoucherTypeSP spVoucherType = new VoucherTypeSP();
                isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decCreditNoteVoucherTypeId);
                if (isAutomatic)
                {
                    txtVoucherNo.ReadOnly = true;
                }
                else
                {
                    txtVoucherNo.ReadOnly = false;
                }

                txtNarration.Text = infoCreditNoteMaster.Narration;
                //GridFill
                DataTable dtbl = new DataTable();
                CreditNoteDetailsSP spCreditNoteDetailsSp = new CreditNoteDetailsSP();
                dtbl = spCreditNoteDetailsSp.CreditNoteDetailsViewByMasterId(decCreditNoteMasterIdForEdit);

                AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
                for (int inI = 0; inI < dtbl.Rows.Count; inI++)
                {
                    dgvCreditNote.Rows.Add();
                    dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(dtbl.Rows[inI]["ledgerId"].ToString());

                    if (Convert.ToDecimal(dtbl.Rows[inI]["debit"].ToString()) == 0)
                    {
                        dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value = "Cr";
                        dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(dtbl.Rows[inI]["credit"].ToString());
                    }
                    else
                    {
                        dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value = "Dr";
                        dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(dtbl.Rows[inI]["debit"].ToString());
                    }
                    dgvCreditNote.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(dtbl.Rows[inI]["exchangeRateId"].ToString());
                    if (dtbl.Rows[inI]["chequeNo"].ToString() != string.Empty)
                    {
                        dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value = dtbl.Rows[inI]["chequeNo"].ToString();
                        dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value = (Convert.ToDateTime(dtbl.Rows[inI]["chequeDate"].ToString())).ToString();
                    }
                    dgvCreditNote.Rows[inI].Cells["dgvtxtDetailsId"].Value = dtbl.Rows[inI]["CreditNoteDetailsId"].ToString();

                    decimal decDetailsId1 = Convert.ToDecimal(dtbl.Rows[inI]["CreditNoteDetailsId"].ToString());
                    decimal decLedgerPostingId = spLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decCreditNoteVoucherTypeId);
                    dgvCreditNote.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString();
                    btnSave.Text = "Update";

                }

                PartyBalanceSP SpPartyBalance = new PartyBalanceSP();
                DataTable dtbl1 = new DataTable();
                dtbl1 = SpPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decCreditNoteVoucherTypeId, strVoucherNo, infoCreditNoteMaster.Date);

                dtblPartyBalance = dtbl1;
                dgvCreditNote.ClearSelection();
                txtDate.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNT:37" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #18
0
        /// <summary>
        /// Function to edit the voucher
        /// </summary>
        /// <param name="decCreditNoteMasterId"></param>
        public void Edit(decimal decCreditNoteMasterId)
        {
            try
            {
                CreditNoteMasterSP spCreditnoteMaster = new CreditNoteMasterSP();
                CreditNoteMasterInfo infoCreditNoteMaster = new CreditNoteMasterInfo();
                CreditNoteDetailsSP spCreditNoteDetails = new CreditNoteDetailsSP();
                CreditNoteDetailsInfo infoCreditNoteDetails = new CreditNoteDetailsInfo();
                ExchangeRateSP spExchangeRate = new ExchangeRateSP();

                /*****************Update in CreditNoteMaster table *************/
                decimal decTotalDebit = 0;
                decimal decTotalCredit = 0;

                infoCreditNoteMaster.CreditNoteMasterId = decCreditNoteMasterId;
                infoCreditNoteMaster.VoucherNo = strVoucherNo;
                infoCreditNoteMaster.InvoiceNo = txtVoucherNo.Text.Trim();
                infoCreditNoteMaster.SuffixPrefixId = decCreditNoteSuffixPrefixId;
                infoCreditNoteMaster.Date = Convert.ToDateTime(txtDate.Text);
                infoCreditNoteMaster.Narration = txtNarration.Text.Trim();
                infoCreditNoteMaster.UserId = PublicVariables._decCurrentUserId;
                infoCreditNoteMaster.VoucherTypeId = decCreditNoteVoucherTypeId;
                infoCreditNoteMaster.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString());
                infoCreditNoteMaster.ExtraDate = DateTime.Now;
                infoCreditNoteMaster.Extra1 = string.Empty;
                infoCreditNoteMaster.Extra2 = string.Empty;

                decTotalDebit = Convert.ToDecimal(txtDebitTotal.Text.Trim());
                decTotalCredit = Convert.ToDecimal(txtCreditTotal.Text.Trim());

                infoCreditNoteMaster.TotalAmount = decTotalDebit;
                decimal decEffectRow = spCreditnoteMaster.CreditNoteMasterEdit(infoCreditNoteMaster);

                /**********************CreditNote Details Edit********************/
                if (decEffectRow > 0)
                {
                    infoCreditNoteDetails.CreditNoteMasterId = decCreditNoteMasterId;
                    infoCreditNoteDetails.ExtraDate = DateTime.Now;
                    infoCreditNoteDetails.Extra1 = string.Empty;
                    infoCreditNoteDetails.Extra2 = string.Empty;

                    //-----------to delete details, LedgerPosting and bankReconciliation of removed rows--------------// 
                    LedgerPostingSP spLedgerPosting = new LedgerPostingSP();

                    foreach (object obj in arrlstOfRemove)
                    {
                        string str = Convert.ToString(obj);
                        spCreditNoteDetails.CreditNoteDetailsDelete(Convert.ToDecimal(str));
                        spLedgerPosting.LedgerPostDeleteByDetailsId(Convert.ToDecimal(str), strVoucherNo, decCreditNoteVoucherTypeId);
                    }
                    spLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decCreditNoteVoucherTypeId, 12);
                    //=============================================================================================//

                    decimal decLedgerId = 0;
                    decimal decDebit = 0;
                    decimal decCredit = 0;
                    decimal decCreditNoteDetailsId = 0;
                    int inRowCount = dgvCreditNote.RowCount;
                    for (int inI = 0; inI < inRowCount; inI++)
                    {
                        if (dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                        {
                            infoCreditNoteDetails.LedgerId = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString());
                            decLedgerId = infoCreditNoteDetails.LedgerId;
                        }
                        if (dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() != string.Empty)
                        {
                            //------------------Currency conversion------------------//
                            decSelectedCurrencyRate = spExchangeRate.GetExchangeRateByExchangeRateId(Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvcmbCurrency"].Value));
                            decAmount = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                            decConvertRate = decAmount * decSelectedCurrencyRate;
                            //======================================================//

                            if (dgvCreditNote.Rows[inI].Cells["dgvcmbDrOrCr"].Value.ToString() == "Dr")
                            {
                                infoCreditNoteDetails.Debit = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                                infoCreditNoteDetails.Credit = 0;

                                decDebit = decConvertRate;
                                decCredit = infoCreditNoteDetails.Credit;
                            }
                            else
                            {
                                infoCreditNoteDetails.Credit = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                                infoCreditNoteDetails.Debit = 0;
                                decDebit = infoCreditNoteDetails.Debit;
                                decCredit = decConvertRate;
                            }
                            infoCreditNoteDetails.ExchangeRateId = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvcmbCurrency"].Value.ToString());
                            if (dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
                            {
                                infoCreditNoteDetails.ChequeNo = dgvCreditNote.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString();
                            }
                            else
                            {
                                infoCreditNoteDetails.ChequeNo = string.Empty;
                            }
                            if (dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value.ToString() != string.Empty)
                            {
                                infoCreditNoteDetails.ChequeDate = Convert.ToDateTime(dgvCreditNote.Rows[inI].Cells["dgvtxtChequeDate"].Value);
                            }
                            else
                            {
                                infoCreditNoteDetails.ChequeDate = DateTime.Now;
                            }
                            if (dgvCreditNote.Rows[inI].Cells["dgvtxtDetailsId"].Value != null && dgvCreditNote.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString() != string.Empty)
                            {
                                infoCreditNoteDetails.CreditNoteDetailsId = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString());
                                spCreditNoteDetails.CreditNoteDetailsEdit(infoCreditNoteDetails);
                                PartyBalanceAddOrEdit(inI);
                                decCreditNoteDetailsId = infoCreditNoteDetails.CreditNoteDetailsId;
                                decimal decLedgerPostId = Convert.ToDecimal(dgvCreditNote.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value.ToString());
                                LedgerPostingEdit(decLedgerPostId, decLedgerId, decCredit, decDebit, decCreditNoteDetailsId, inI);

                            }
                            else
                            {
                                decCreditNoteDetailsId = spCreditNoteDetails.CreditNoteDetailsAdd(infoCreditNoteDetails);
                                PartyBalanceAddOrEdit(inI);
                                LedgerPosting(decLedgerId, decCredit, decDebit, decCreditNoteDetailsId, inI);
                            }

                        }

                    }
                    DeletePartyBalanceOfRemovedRow();
                    Messages.UpdatedMessage();
                    

                }
                //----------------If print after save is enable-----------------------//
                SettingsSP spSettings = new SettingsSP();
                if (cbxPrintAfterSave.Checked)
                {
                    if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                    {
                        PrintForDotMatrix(infoCreditNoteMaster.CreditNoteMasterId);
                    }
                    else
                    {
                        Print(infoCreditNoteMaster.CreditNoteMasterId);
                    }
                }

                //===================================================================//
                if (CreditNoteRegisterObj != null)
                {
                    this.Close();
                    CreditNoteRegisterObj.Enabled = true;

                }
                else if (frmCreditNoteReportObj != null)
                {
                    this.Close();
                    frmCreditNoteReportObj.Enabled = true;

                }
                else
                {
                    clear();
                }
                if (frmBillallocationObj != null)
                {
                    this.Close();
                }
                if (frmDayBookObj != null)
                {
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNT:35" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to print the Report
        /// </summary>
        public void Print()
        {
            try
            {
                string strFromDate = txtFromDate.Text;
                string strToDate = txtToDate.Text;
                decimal decVoucherTypeId = Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString());
                decimal decLedgerId = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString());

                CreditNoteMasterSP SpCreditNoteMaster = new CreditNoteMasterSP();
                DataSet dsCreditNoteReport = SpCreditNoteMaster.CreditNoteReportPrinting(strFromDate, strToDate, decVoucherTypeId, decLedgerId, 1);
                frmReport frmReport = new frmReport();
                frmReport.MdiParent = formMDI.MDIObj;
                frmReport.CreditNoteReportPrinting(dsCreditNoteReport);

            }
            catch (Exception ex)
            {
                MessageBox.Show("CRNTREP6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }