Esempio n. 1
0
        /// <summary>
        /// For the shortcut keys
        /// Esc for form closing
        /// ctrl+s for save
        /// ctrl+d for delete
        /// alt+c for ledger creation
        /// ctrl+f for ledger popup
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmJournalVoucher_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Escape)
                {
                    if (PublicVariables.isMessageClose)
                    {
                        Messages.CloseMessage(this);

                    }
                    else
                    {
                        this.Close();
                    }
                }

                if (dgvJournalVoucher.RowCount > 0)
                {


                    //-----------------------for ledger creation----------------------------------//
                    if (e.KeyCode == Keys.C && Control.ModifierKeys == Keys.Alt)//Ledger creation
                    {
                        if (dgvJournalVoucher.CurrentCell == dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"])
                        {
                           // SendKeys.Send("{F10}");
                            frmAccountLedger accounLedgerObj = new frmAccountLedger();
                            accounLedgerObj.MdiParent = formMDI.MDIObj;
                            if (dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].Value != null && dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                            {
                                string strLedgerName = dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].FormattedValue.ToString();
                                accounLedgerObj.CallFromJournalVoucher(this, strLedgerName);
                            }
                            else
                            {
                                string strLedgerName = string.Empty;
                                accounLedgerObj.CallFromJournalVoucher(this, strLedgerName);
                            }
                        }

                    }
                    //========================================================================//

                    //--------------------For ledger Popup------------------------------------//

                    if (e.KeyCode == Keys.F && Control.ModifierKeys == Keys.Control)//Ledger popup
                    {
                        if (dgvJournalVoucher.CurrentCell == dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"])
                        {
                            frmLedgerPopup frmLedgerPopupObj = new frmLedgerPopup();
                            frmLedgerPopupObj.MdiParent = formMDI.MDIObj;

                            if (dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].Value != null && dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                            {
                                decLedgerIdForPopUp = Convert.ToDecimal(dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].Value.ToString());
                                frmLedgerPopupObj.CallFromJournalVoucher(this, decLedgerIdForPopUp, string.Empty);

                            }
                        }

                    }
                    //========================================================================// 


                    if (e.KeyCode == Keys.F && Control.ModifierKeys == Keys.Control) //Pop Up
                    {
                        if (dgvJournalVoucher.CurrentCell == dgvJournalVoucher.CurrentRow.Cells["dgvcmbCurrency"])
                        {
                            frmCurrencyObj = new frmCurrencyDetails();
                            frmCurrencyObj.MdiParent = formMDI.MDIObj;
                            if (dgvJournalVoucher.CurrentRow.Cells["dgvcmbCurrency"].Value != null && dgvJournalVoucher.CurrentRow.Cells["dgvcmbCurrency"].Value.ToString() != string.Empty)
                            {
                                frmCurrencyObj.CallFromJournalVoucher(this, Convert.ToDecimal(dgvJournalVoucher.CurrentRow.Cells["dgvcmbCurrency"].Value.ToString()));
                            }
                        }
                    }

                }


                //-----------------------CTRL+S Save-----------------------------//
                if (e.KeyCode == Keys.S && Control.ModifierKeys == Keys.Control) //Save
                {
                    btnSave_Click(sender, e);
                }
                //===============================================================//

                //-----------------------CTRL+D Delete-----------------------------//
                if (e.KeyCode == Keys.D && Control.ModifierKeys == Keys.Control) //Delete
                {
                    if (btnDelete.Enabled)
                    {
                        btnDelete_Click(sender, e);
                    }
                }
                //=====================================================================//
            }
            catch (Exception ex)
            {
                MessageBox.Show("JV51:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }