/// <summary>
 /// Call Corresponding Voucher to View details for updation in edit mode
 /// </summary>
 public void GotoPurchaseInvoice()
 {
     try
     {
         PurchaseMasterSP purchasemastersp = new PurchaseMasterSP();
         PurchaseMasterInfo purchasemasterinfo = new PurchaseMasterInfo();
         purchasemasterinfo = purchasemastersp.PurchaseMasterView(Convert.ToDecimal(dgvVoucherSearch.CurrentRow.Cells["Id"].Value.ToString()));
         if (purchasemasterinfo.PurchaseMasterId != 0)
         {
             frmPurchaseInvoice objfrmPurchaseInvoice = new frmPurchaseInvoice();
             frmPurchaseInvoice open = Application.OpenForms["frmPurchaseInvoice"] as frmPurchaseInvoice;
             if (open == null)
             {
                 objfrmPurchaseInvoice.WindowState = FormWindowState.Normal;
                 objfrmPurchaseInvoice.MdiParent = formMDI.MDIObj;
                 objfrmPurchaseInvoice.Show();
                 objfrmPurchaseInvoice.CallFromVoucherSerach(this, Convert.ToDecimal(dgvVoucherSearch.CurrentRow.Cells["Id"].Value.ToString()));
             }
             else
             {
                 open.MdiParent = formMDI.MDIObj;
                 if (open.WindowState == FormWindowState.Minimized)
                 {
                     open.WindowState = FormWindowState.Normal;
                 }
                 else
                 {
                     open.Activate();
                 }
               
                 open.CallFromVoucherSerach(this, Convert.ToDecimal(dgvVoucherSearch.CurrentRow.Cells["Id"].Value.ToString()));
                 open.BringToFront();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("VS23:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// On form closing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmLedgerPopup_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (frmMonthlySalaryRegisterObj != null)
                {
                    frmMonthlySalaryRegisterObj = Application.OpenForms["frmMonthlySalaryRegister"] as frmMonthlySalaryRegister;
                    if (frmMonthlySalaryRegisterObj == null)
                    {
                        frmMonthlySalaryRegisterObj = new frmMonthlySalaryRegister();
                        frmMonthlySalaryRegisterObj.MdiParent = formMDI.MDIObj;
                        frmMonthlySalaryRegisterObj.Show();
                    }
                    else
                    {
                        frmMonthlySalaryRegisterObj.Activate();
                    }
                }
                if (frmAdvancePaymentObj != null)
                {
                    frmAdvancePaymentObj = Application.OpenForms["frmAdvancePayment"] as frmAdvancePayment;
                    if (frmAdvancePaymentObj == null)
                    {
                        frmAdvancePaymentObj = new frmAdvancePayment();
                        frmAdvancePaymentObj.MdiParent = formMDI.MDIObj;
                        frmAdvancePaymentObj.Show();
                    }
                    else
                    {
                        frmAdvancePaymentObj.Activate();
                    }
                }
                if (frmMonthlySalaryVoucherObj != null)
                {
                    frmMonthlySalaryVoucherObj = Application.OpenForms["frmMonthlySalaryVoucher"] as frmMonthlySalaryVoucher;
                    if (frmMonthlySalaryVoucherObj == null)
                    {
                        frmMonthlySalaryVoucherObj = new frmMonthlySalaryVoucher();
                        frmMonthlySalaryVoucherObj.MdiParent = formMDI.MDIObj;
                        frmMonthlySalaryVoucherObj.Show();
                    }
                    else
                    {
                        frmMonthlySalaryVoucherObj.Activate();
                    }
                }
                if (frmDailySalaryVoucherObj != null)
                {
                    frmDailySalaryVoucherObj = Application.OpenForms["frmDailySalaryVoucher"] as frmDailySalaryVoucher;
                    if (frmDailySalaryVoucherObj == null)
                    {
                        frmDailySalaryVoucherObj = new frmDailySalaryVoucher();
                        frmDailySalaryVoucherObj.MdiParent = formMDI.MDIObj;
                        frmDailySalaryVoucherObj.Show();
                    }
                    else
                    {
                        frmDailySalaryVoucherObj.Activate();
                    }
                }
                if (frmJournalVoucherObj != null)
                {
                    frmJournalVoucherObj.Enabled = true;
                }
                if (frmReceiptVoucherObj != null)
                {
                    frmReceiptVoucherObj.Enabled = true;
                }
                if (frmContraVoucherObj != null)
                {
                    frmContraVoucherObj = Application.OpenForms["frmContraVoucher"] as frmContraVoucher;
                    if (frmContraVoucherObj == null)
                    {
                        frmContraVoucherObj = new frmContraVoucher();
                        frmContraVoucherObj.MdiParent = formMDI.MDIObj;
                        frmContraVoucherObj.Show();
                    }
                    else
                    {
                        frmContraVoucherObj.Activate();
                    }
                }
                if (frmPaymentVoucherObj != null)
                {
                    frmPaymentVoucherObj.Enabled = true;
                }

                if (frmDebitNoteObj != null)
                {
                    frmDebitNoteObj.Enabled = true;
                }
                if (frmCreditNoteObj != null)
                {
                    frmCreditNoteObj.Enabled = true;
                }
                if (frmPdcPayableObj != null)
                {
                    frmPdcPayableObj.Enabled = true;
                }
                if (frmpdReceivableObj != null)
                {
                    frmpdReceivableObj.Enabled = true;
                }
                if (frmMaterialReceiptObj != null)
                {
                    frmMaterialReceiptObj.Enabled = true;
                }
                if (frmSalesInvoiceObj != null)
                {
                    frmSalesInvoiceObj.Enabled = true;
                }
                if (frmPOSObj != null)
                {
                    frmPOSObj.Enabled = true;
                }

                if (frmMaterialReceiptObj != null)
                {
                    frmMaterialReceiptObj = Application.OpenForms["frmMaterialReceipt"] as frmMaterialReceipt;
                    if (frmMaterialReceiptObj == null)
                    {
                        frmMaterialReceiptObj = new frmMaterialReceipt();
                        frmMaterialReceiptObj.MdiParent = formMDI.MDIObj;
                        frmMaterialReceiptObj.Show();
                    }
                    else
                    {
                        frmMaterialReceiptObj.Activate();
                    }
                }

                if (frmPurchaseInvoiceObj != null)
                {
                    frmPurchaseInvoiceObj = Application.OpenForms["frmPurchaseInvoice"] as frmPurchaseInvoice;
                    if (frmPurchaseInvoiceObj == null)
                    {
                        frmPurchaseInvoiceObj = new frmPurchaseInvoice();
                        frmPurchaseInvoiceObj.MdiParent = formMDI.MDIObj;
                        frmPurchaseInvoiceObj.Show();
                    }
                    else
                    {
                        frmPurchaseInvoiceObj.Activate();
                    }
                }
                if (frmServiceVoucherObj != null)
                {
                    frmServiceVoucherObj.Enabled = true;
                }

                dgvLedgerPopup.ClearSelection();
            }
            catch (Exception ex)
            {
                MessageBox.Show("LP35:" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }