Example #1
0
        /// <summary>
        /// Function to call corresponding form from ledger
        /// </summary>
        /// <param name="strTypeofVoucher"></param>
        /// <param name="decMasterId"></param>
        public void CallToCorrespondingForm(string strTypeofVoucher, decimal decMasterId)
        {
            try
            {
                switch (strTypeofVoucher)
                {
                case "Contra Voucher":
                    frmContraVoucher frmContraVoucherObj  = new frmContraVoucher();
                    frmContraVoucher frmContraVoucherOpen = Application.OpenForms["frmContraVoucher"] as frmContraVoucher;
                    if (frmContraVoucherOpen == null)
                    {
                        frmContraVoucherObj.MdiParent = this.MdiParent;
                        frmContraVoucherObj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmContraVoucherOpen.CallFromLedgerDetails(this, decMasterId);
                        if (frmContraVoucherOpen.WindowState == FormWindowState.Minimized)
                        {
                            frmContraVoucherOpen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "Payment Voucher":
                    frmPaymentVoucher frmPaymentVoucherObj  = new frmPaymentVoucher();
                    frmPaymentVoucher frmPaymentVoucherOpen = Application.OpenForms["frmPaymentVoucher"] as frmPaymentVoucher;
                    if (frmPaymentVoucherOpen == null)
                    {
                        frmPaymentVoucherObj.MdiParent = this.MdiParent;
                        frmPaymentVoucherObj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmPaymentVoucherOpen.CallFromLedgerDetails(this, decMasterId);
                        if (frmPaymentVoucherOpen.WindowState == FormWindowState.Minimized)
                        {
                            frmPaymentVoucherOpen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "Receipt Voucher":
                    frmReceiptVoucher frmReceiptVoucherObj  = new frmReceiptVoucher();
                    frmReceiptVoucher frmReceiptVoucherOpen = Application.OpenForms["frmReceiptVoucher"] as frmReceiptVoucher;
                    if (frmReceiptVoucherOpen == null)
                    {
                        frmReceiptVoucherObj.MdiParent = this.MdiParent;
                        frmReceiptVoucherObj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmReceiptVoucherOpen.CallFromLedgerDetails(this, decMasterId);
                        if (frmReceiptVoucherOpen.WindowState == FormWindowState.Minimized)
                        {
                            frmReceiptVoucherOpen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "Journal Voucher":
                    frmJournalVoucher frmJournalVoucherObj  = new frmJournalVoucher();
                    frmJournalVoucher frmJournalVoucherOpen = Application.OpenForms["frmJournalVoucher"] as frmJournalVoucher;
                    if (frmJournalVoucherOpen == null)
                    {
                        frmJournalVoucherObj.MdiParent = this.MdiParent;
                        frmJournalVoucherObj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmJournalVoucherOpen.CallFromLedgerDetails(this, decMasterId);
                        if (frmJournalVoucherOpen.WindowState == FormWindowState.Minimized)
                        {
                            frmJournalVoucherOpen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "PDC Clearance":
                    frmPdcClearance frmPdcClearanceObj  = new frmPdcClearance();
                    frmPdcClearance frmPdcClearanceOpen = Application.OpenForms["frmPdcClearance"] as frmPdcClearance;
                    if (frmPdcClearanceOpen == null)
                    {
                        frmPdcClearanceObj.MdiParent = this.MdiParent;
                        frmPdcClearanceObj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmPdcClearanceOpen.CallFromLedgerDetails(this, decMasterId);
                        if (frmPdcClearanceOpen.WindowState == FormWindowState.Minimized)
                        {
                            frmPdcClearanceOpen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "PDC Payable":
                    frmPdcPayable frmPDCPayableObj  = new frmPdcPayable();
                    frmPdcPayable frmPDCPayableOpen = Application.OpenForms["frmPdcPayable"] as frmPdcPayable;
                    if (frmPDCPayableOpen == null)
                    {
                        frmPDCPayableObj.MdiParent = this.MdiParent;
                        frmPDCPayableObj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmPDCPayableOpen.CallFromLedgerDetails(this, decMasterId);
                        if (frmPDCPayableOpen.WindowState == FormWindowState.Minimized)
                        {
                            frmPDCPayableOpen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "PDC Receivable":
                    frmPdcReceivable frmPdcReceivableObj  = new frmPdcReceivable();
                    frmPdcReceivable frmPdcReceivableOpen = Application.OpenForms["frmPdcReceivable"] as frmPdcReceivable;
                    if (frmPdcReceivableOpen == null)
                    {
                        frmPdcReceivableObj.MdiParent = this.MdiParent;
                        frmPdcReceivableObj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmPdcReceivableOpen.CallFromLedgerDetails(this, decMasterId);
                        if (frmPdcReceivableOpen.WindowState == FormWindowState.Minimized)
                        {
                            frmPdcReceivableOpen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "Purchase Invoice":
                    frmPurchaseInvoice frmPurchaseInvoiceObj  = new frmPurchaseInvoice();
                    frmPurchaseInvoice frmPurchaseInvoiveOpen = Application.OpenForms["frmPurchaseInvoice"] as frmPurchaseInvoice;
                    if (frmPurchaseInvoiveOpen == null)
                    {
                        frmPurchaseInvoiceObj.MdiParent = this.MdiParent;
                        frmPurchaseInvoiceObj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmPurchaseInvoiveOpen.CallFromLedgerDetails(this, decMasterId);
                        if (frmPurchaseInvoiveOpen.WindowState == FormWindowState.Minimized)
                        {
                            frmPurchaseInvoiveOpen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "Purchase Return":
                    frmPurchaseReturn frmPurchaseReturnObj  = new frmPurchaseReturn();
                    frmPurchaseReturn frmPurchaseReturnOpen = Application.OpenForms["frmPurchaseReturn"] as frmPurchaseReturn;
                    if (frmPurchaseReturnOpen == null)
                    {
                        frmPurchaseReturnObj.MdiParent = this.MdiParent;
                        frmPurchaseReturnObj.CallFromLedgerDetails(this, decMasterId, true);
                    }
                    else
                    {
                        frmPurchaseReturnOpen.CallFromLedgerDetails(this, decMasterId, true);
                        if (frmPurchaseReturnOpen.WindowState == FormWindowState.Minimized)
                        {
                            frmPurchaseReturnOpen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "Sales Invoice":
                    if (dgvLedgerDetails.CurrentRow.Cells["dgvtxtpos"].Value.ToString() == "False")
                    {
                        frmSalesInvoice frmSalesInvoiceObj  = new frmSalesInvoice();
                        frmSalesInvoice frmSalesInvoiveOpen = Application.OpenForms["frmSalesInvoice"] as frmSalesInvoice;
                        if (frmSalesInvoiveOpen == null)
                        {
                            frmSalesInvoiceObj.MdiParent = this.MdiParent;
                            frmSalesInvoiceObj.CallFromLedgerDetails(this, decMasterId);
                        }
                        else
                        {
                            frmSalesInvoiveOpen.CallFromLedgerDetails(this, decMasterId);
                            if (frmSalesInvoiveOpen.WindowState == FormWindowState.Minimized)
                            {
                                frmSalesInvoiveOpen.WindowState = FormWindowState.Normal;
                            }
                        }
                    }
                    else
                    {
                        frmPOS frmposObj  = new frmPOS();
                        frmPOS frmposOpen = Application.OpenForms["frmPOS"] as frmPOS;
                        if (frmposOpen == null)
                        {
                            frmposObj.MdiParent = this.MdiParent;
                            frmposObj.CallFromLedgerDetails(this, decMasterId);
                        }
                        else
                        {
                            frmposOpen.CallFromLedgerDetails(this, decMasterId);
                            if (frmposOpen.WindowState == FormWindowState.Minimized)
                            {
                                frmposOpen.WindowState = FormWindowState.Normal;
                            }
                        }
                    }
                    break;

                case "Sales Return":
                    frmSalesReturn frmSalesReturnObj  = new frmSalesReturn();
                    frmSalesReturn frmSalesReturnOpen = Application.OpenForms["frmSalesReturn"] as frmSalesReturn;
                    if (frmSalesReturnOpen == null)
                    {
                        frmSalesReturnObj.MdiParent = this.MdiParent;
                        frmSalesReturnObj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmSalesReturnOpen.CallFromLedgerDetails(this, decMasterId);
                        if (frmSalesReturnOpen.WindowState == FormWindowState.Minimized)
                        {
                            frmSalesReturnOpen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "Service Voucher":
                    frmServiceVoucher frmServiceVoucherObj  = new frmServiceVoucher();
                    frmServiceVoucher frmServiceVoucherOpen = Application.OpenForms["frmServiceVoucher"] as frmServiceVoucher;
                    if (frmServiceVoucherOpen == null)
                    {
                        frmServiceVoucherObj.MdiParent = this.MdiParent;
                        frmServiceVoucherObj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmServiceVoucherOpen.CallFromLedgerDetails(this, decMasterId);
                        if (frmServiceVoucherOpen.WindowState == FormWindowState.Minimized)
                        {
                            frmServiceVoucherOpen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "Credit Note":
                    frmCreditNote frmCreditNoteobj  = new frmCreditNote();
                    frmCreditNote frmCreditNoteOpen = Application.OpenForms["frmCreditNote"] as frmCreditNote;
                    if (frmCreditNoteOpen == null)
                    {
                        frmCreditNoteobj.MdiParent = this.MdiParent;
                        frmCreditNoteobj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmCreditNoteOpen.CallFromLedgerDetails(this, decMasterId);
                        if (frmCreditNoteOpen.WindowState == FormWindowState.Minimized)
                        {
                            frmCreditNoteOpen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "Debit Note":
                    frmDebitNote frmDebitNoteObj  = new frmDebitNote();
                    frmDebitNote frmDebitNoteOpen = Application.OpenForms["frmDebitNote"] as frmDebitNote;
                    if (frmDebitNoteOpen == null)
                    {
                        frmDebitNoteObj.MdiParent = this.MdiParent;
                        frmDebitNoteObj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmDebitNoteOpen.CallFromLedgerDetails(this, decMasterId);
                        if (frmDebitNoteOpen.WindowState == FormWindowState.Minimized)
                        {
                            frmDebitNoteOpen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "Advance Payment":
                    frmAdvancePayment frmAdvancePaymentObj  = new frmAdvancePayment();
                    frmAdvancePayment frmAdvancePaymentopen = Application.OpenForms["frmAdvancePayment"] as frmAdvancePayment;
                    if (frmAdvancePaymentopen == null)
                    {
                        frmAdvancePaymentObj.MdiParent = this.MdiParent;
                        frmAdvancePaymentObj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmAdvancePaymentopen.CallFromLedgerDetails(this, decMasterId);
                        if (frmAdvancePaymentopen.WindowState == FormWindowState.Minimized)
                        {
                            frmAdvancePaymentopen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;

                case "Monthly Salary Voucher":
                    frmMonthlySalaryVoucher frmMonthlySalaryVoucherObj  = new frmMonthlySalaryVoucher();
                    frmMonthlySalaryVoucher frmMonthlySalaryVoucheropen = Application.OpenForms["frmMonthlySalaryVoucher"] as frmMonthlySalaryVoucher;
                    if (frmMonthlySalaryVoucheropen == null)
                    {
                        frmMonthlySalaryVoucherObj.MdiParent = this.MdiParent;
                        frmMonthlySalaryVoucherObj.CallFromLedgerDetails(this, decMasterId);
                    }
                    else
                    {
                        frmMonthlySalaryVoucheropen.CallFromLedgerDetails(this, decMasterId);
                        if (frmMonthlySalaryVoucheropen.WindowState == FormWindowState.Minimized)
                        {
                            frmMonthlySalaryVoucheropen.WindowState = FormWindowState.Normal;
                        }
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                formMDI.infoError.ErrorString = "LEDDET5:" + ex.Message;
            }
        }