Exemplo n.º 1
0
 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     if (keyData == Keys.Enter)
     {
         if (this.form_state == FORM_STATE.ADD || this.form_state == FORM_STATE.EDIT)
         {
             if (this.current_focused_control == this.txtRemark)
             {
                 this.toolStripSave.PerformClick();
                 return true;
             }
             else
             {
                 SendKeys.Send("{TAB}");
                 return true;
             }
         }
         if (this.form_state == FORM_STATE.ADDF8 || this.form_state == FORM_STATE.EDITF8)
         {
             if (this.current_focused_control.Name != "inline_desc")
             {
                 SendKeys.Send("{TAB}");
                 return true;
             }
         }
     }
     if (keyData == Keys.Escape)
     {
         this.toolStripStop.PerformClick();
         return true;
     }
     if (keyData == Keys.Tab)
     {
         if (this.form_state == FORM_STATE.READ)
         {
             DataInfo data_info = new DataInfo();
             data_info.lblDataTable.Text = "DEALER";
             data_info.lblExpression.Text = (this.sort_mode == SORT_MODE.DEALER ? "dealer" : this.GetSortFieldName() + "+dealer");
             data_info.lblRecBy.Text = this.dealer.users_name;
             data_info.lblRecDate.pickedDate(this.dealer.chgdat);
             data_info.lblTime.ForeColor = Color.DarkGray;
             data_info.lblRecTime.BackColor = Color.WhiteSmoke;
             data_info.lblRecNo.Text = this.dealer.id.ToString();
             data_info.lblTotalRec.Text = this.dealer_id_list.Max(t => t.id).ToString();
             data_info.ShowDialog();
             return true;
         }
         if (this.form_state == FORM_STATE.READF8)
         {
             if (this.dgvMsg.Rows[this.dgvMsg.CurrentCell.RowIndex].Tag is D_msg)
             {
                 D_msg d_msg = (D_msg)this.dgvMsg.Rows[this.dgvMsg.CurrentCell.RowIndex].Tag;
                 CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "dmsg/get_max_id");
                 ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(get.data);
                 if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                 {
                     DataInfo data_info = new DataInfo();
                     data_info.lblDataTable.Text = "D_MSG";
                     data_info.lblExpression.Text = "dealer+date";
                     data_info.lblRecBy.Text = d_msg.users_name;
                     data_info.lblRecDate.pickedDate(d_msg.date);
                     data_info.lblRecTime.Text = d_msg.time;
                     data_info.lblRecNo.Text = d_msg.id.ToString();
                     data_info.lblTotalRec.Text = sr.d_msg[0].id.ToString(); // this.dealer_id_list.Max(t => t.id).ToString();
                     data_info.ShowDialog();
                     return true;
                 }
             }
             else
             {
                 return true;
             }
         }
         if (this.form_state == FORM_STATE.READF7)
         {
             return true;
         }
     }
     if (keyData == Keys.F3)
     {
         if (this.form_state == FORM_STATE.READ)
         {
             this.tabControl1.SelectedTab = this.tabPage1;
             return true;
         }
     }
     if (keyData == Keys.F4)
     {
         if (this.form_state == FORM_STATE.READ)
         {
             this.tabControl1.SelectedTab = this.tabPage2;
             return true;
         }
     }
     if (keyData == Keys.F5)
     {
         this.toolStripReload.PerformClick();
         return true;
     }
     if (keyData == Keys.PageUp && this.form_state == FORM_STATE.READ)
     {
         this.toolStripPrev.PerformClick();
         return true;
     }
     if (keyData == Keys.PageDown && this.form_state == FORM_STATE.READ)
     {
         this.toolStripNext.PerformClick();
         return true;
     }
     if (keyData == (Keys.Control | Keys.Home) && this.form_state == FORM_STATE.READ)
     {
         this.toolStripFirst.PerformClick();
         return true;
     }
     if (keyData == (Keys.Control | Keys.End) && this.form_state == FORM_STATE.READ)
     {
         this.toolStripLast.PerformClick();
         return true;
     }
     if (keyData == (Keys.Alt | Keys.A))
     {
         if (this.form_state == FORM_STATE.READ)
         {
             this.toolStripAdd.PerformClick();
             return true;
         }
         if (this.form_state == FORM_STATE.READF8)
         {
             this.AddFormMsg();
             return true;
         }
     }
     if (keyData == (Keys.Alt | Keys.E))
     {
         if (this.form_state == FORM_STATE.READ)
         {
             this.toolStripEdit.PerformClick();
             return true;
         }
         if(this.form_state == FORM_STATE.READF8)
         {
             this.EditFormMsg(1);
             return true;
         }
     }
     if (keyData == (Keys.Alt | Keys.D))
     {
         if (this.form_state == FORM_STATE.READ)
         {
             this.toolStripDelete.PerformClick();
             return true;
         }
         if (this.form_state == FORM_STATE.READF8)
         {
             this.DeleteMsg();
             return true;
         }
     }
     if (keyData == (Keys.Alt | Keys.S))
     {
         this.toolStripSearchCode.PerformClick();
         return true;
     }
     if (keyData == (Keys.Control | Keys.L))
     {
         this.toolStripInquiryAll.PerformClick();
         return true;
     }
     if (keyData == (Keys.Alt | Keys.K))
     {
         this.toolStripInquiryCondition.PerformClick();
         return true;
     }
     if (keyData == (Keys.Alt | Keys.L))
     {
         this.toolStripInquiryRest.PerformClick();
         return true;
     }
     if (keyData == (Keys.Alt | Keys.P))
     {
         this.toolStripPrintLabel3Col.PerformClick();
         return true;
     }
     if (keyData == (Keys.Control | Keys.P))
     {
         this.toolStripPrintLittleEnv.PerformClick();
         return true;
     }
     if (keyData == (Keys.Alt | Keys.D2))
     {
         this.toolStripSearchContact.PerformClick();
         return true;
     }
     if (keyData == (Keys.Alt | Keys.D3))
     {
         this.toolStripSearchName.PerformClick();
         return true;
     }
     if (keyData == (Keys.Alt | Keys.D4))
     {
         this.toolStripSearchArea.PerformClick();
         return true;
     }
     if (keyData == Keys.F6 && this.current_focused_control == this.txtArea && (this.form_state == FORM_STATE.ADD || this.form_state == FORM_STATE.EDIT))
     {
         this.btnBrowseArea.PerformClick();
         return true;
     }
     if (keyData == Keys.F9 && (this.form_state == FORM_STATE.ADD || this.form_state == FORM_STATE.EDIT))
     {
         this.toolStripSave.PerformClick();
         return true;
     }
     if (keyData == Keys.F7 && this.form_state == FORM_STATE.READ)
     {
         this.tabControl1.SelectedTab = this.tabPage2;
         this.dgvSerial.Focus();
         this.FormReadItemF7();
         return true;
     }
     if (keyData == Keys.F8 && this.form_state == FORM_STATE.READ)
     {
         this.tabControl1.SelectedTab = this.tabPage1;
         this.dgvMsg.Focus();
         this.FormReadItemF8();
         return true;
     }
     return base.ProcessCmdKey(ref msg, keyData);
 }
Exemplo n.º 2
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.Tab && this.form_mode == FORM_MODE.READ)
            {
                DataInfo data_info = new DataInfo();

                int max_id = 0;
                foreach (Serial s in this.serial_id_list)
                {
                    if (s.id > max_id)
                    {
                        max_id = s.id;
                    }
                }

                data_info.lblDataTable.Text = "Serial";
                data_info.lblExpression.Text = (this.sortMode == SORT_SN ? this.sortMode : this.sortMode + "+sernum");
                data_info.lblRecBy.Text = this.serial.users_name;
                data_info.lblRecDate.pickedDate(this.serial.chgdat);
                data_info.lblRecNo.Text = this.serial.id.ToString();
                data_info.lblTotalRec.Text = max_id.ToString();
                data_info.lblTime.ForeColor = Color.DarkGray;
                data_info.lblRecTime.BackColor = Color.WhiteSmoke;
                data_info.ShowDialog();
                return true;
            }
            if (keyData == Keys.Tab && this.form_mode == FORM_MODE.READ_ITEM)
            {
                if (this.dgvProblem.Rows[this.dgvProblem.CurrentCell.RowIndex].Tag is Problem)
                {
                    CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "problem/get_info&id=" + ((Problem)this.dgvProblem.Rows[this.dgvProblem.CurrentCell.RowIndex].Tag).id.ToString());
                    ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(get.data);

                    if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                    {
                        if (sr.problem.Count > 0)
                        {
                            DataInfo data_info = new DataInfo();
                            data_info.lblDataTable.Text = "Problem";
                            data_info.lblExpression.Text = "sernum+date";
                            data_info.lblRecBy.Text = sr.problem.First<Problem>().users_name;
                            data_info.lblRecDate.pickedDate(sr.problem.First<Problem>().date);
                            data_info.lblRecTime.Text = sr.problem.First<Problem>().time;
                            data_info.lblRecNo.Text = sr.problem.First<Problem>().id.ToString();
                            data_info.lblTotalRec.Text = sr.message;
                            data_info.ShowDialog();
                        }
                    }

                }
                return true;
            }
            if (keyData == (Keys.Alt | Keys.A))
            {
                if (this.form_mode == FORM_MODE.READ_ITEM)
                {
                    Problem pattern = (this.dgvProblem.CurrentCell != null && this.dgvProblem.Rows[this.dgvProblem.CurrentCell.RowIndex].Tag is Problem ? (Problem)this.dgvProblem.Rows[this.dgvProblem.CurrentCell.RowIndex].Tag : null);
                    int problem_count = (this.is_problem_im_only ? this.problem_im_only.Count : this.problem.Count);
                    this.dgvProblem.Rows[problem_count].Cells[1].Selected = true;
                    this.showInlineProblemForm(this.dgvProblem.Rows[problem_count], 1, pattern);
                    return true;
                }
                else if (this.form_mode == FORM_MODE.READ)
                {
                    this.toolStripAdd.PerformClick();
                    return true;
                }
            }
            if (keyData == (Keys.Alt | Keys.E))
            {
                if (this.form_mode == FORM_MODE.READ_ITEM)
                {
                    if (this.dgvProblem.Rows[this.dgvProblem.CurrentCell.RowIndex].Tag is Problem)
                    {
                        this.showInlineProblemForm(this.dgvProblem.Rows[this.dgvProblem.CurrentCell.RowIndex]);
                        return true;
                    }
                }
                else
                {
                    this.toolStripEdit.PerformClick();
                    return true;
                }
            }
            if (keyData == Keys.Enter && (this.form_mode == FORM_MODE.ADD || this.form_mode == FORM_MODE.EDIT || this.form_mode == FORM_MODE.ADD_ITEM || this.form_mode == FORM_MODE.EDIT_ITEM))
            {
                if (this.current_focused_control == this.dtVerextdat || this.current_focused_control.Name == "inline_problem_probdesc")
                {
                    this.toolStripSave.PerformClick();
                    return true;
                }

                SendKeys.Send("{TAB}");
                return true;
            }
            if (keyData == Keys.Escape)
            {
                //if (!(this.current_focused_control is CustomDateTimePicker)) // if current_focused_control is not CustomDateTimePicker
                //{
                //    if (!(this.current_focused_control is CustomComboBox)) // and if current_focused_control is not CustomComboBox
                //    {
                //        this.toolStripStop.PerformClick();
                //        this.current_focused_control = null;
                //        return true;
                //    }
                //    else
                //    {
                //        if (!((CustomComboBox)this.current_focused_control).item_shown) // if CustomComboBox is currently not showing items.
                //        {
                //            this.toolStripStop.PerformClick();
                //            this.current_focused_control = null;
                //            return true;
                //        }
                //        else // then if CustomComboBox is currently showing calendar just close the items portion.
                //        {
                //            SendKeys.Send("{F4}");
                //            return true;
                //        }
                //    }
                //}
                //else
                //{
                //    if (!((CustomDateTimePicker)this.current_focused_control).calendar_shown) // if CustomDateTimePicker is currently not showing calendar.
                //    {
                //        this.toolStripStop.PerformClick();
                //        this.current_focused_control = null;
                //        return true;
                //    }
                //    // then if CustomDateTimePicker is currently showing calendar just close the calendar.
                //}
                //if (this.dtPurdat.dateTimePicker1.Focused || this.dtManual.dateTimePicker1.Focused || this.dtExpdat.dateTimePicker1.Focused || this.dtVerextdat.dateTimePicker1.Focused || (this.cbVerext.comboBox1.Focused && this.cbVerext.comboBox1.DroppedDown))
                if (this.cbVerext.comboBox1.Focused && this.cbVerext.comboBox1.DroppedDown)
                {
                    SendKeys.Send("{F4}");
                    return true;
                }
                this.toolStripStop.PerformClick();
                return true;
            }
            if (keyData == Keys.F6)
            {
                if (this.current_focused_control != null)
                {
                    if (this.current_focused_control == this.txtArea)
                    {
                        this.btnBrowseArea.PerformClick();
                        return true;
                    }
                    else if (this.current_focused_control == this.txtBusityp)
                    {
                        this.btnBrowseBusityp.PerformClick();
                        return true;
                    }
                    else if (this.current_focused_control == this.txtDealer)
                    {
                        this.btnBrowseDealer.PerformClick();
                        return true;
                    }
                    else if (this.current_focused_control == this.txtHowknown)
                    {
                        this.btnBrowseHowknown.PerformClick();
                        return true;
                    }
                    else if (this.current_focused_control == this.dtPurdat)
                    {
                        this.dtPurdat.dateTimePicker1.Focus();
                        SendKeys.Send("{F4}");
                        return true;
                    }
                    else if (this.current_focused_control == this.dtExpdat)
                    {
                        this.dtExpdat.dateTimePicker1.Focus();
                        SendKeys.Send("{F4}");
                        return true;
                    }
                    else if (this.current_focused_control == this.dtManual)
                    {
                        this.dtManual.dateTimePicker1.Focus();
                        SendKeys.Send("{F4}");
                        return true;
                    }
                    else if (this.current_focused_control == this.dtVerextdat)
                    {
                        this.dtVerextdat.dateTimePicker1.Focus();
                        SendKeys.Send("{F4}");
                        return true;
                    }
                    else if (this.current_focused_control == this.cbVerext)
                    {
                        SendKeys.Send("{F4}");
                        return true;
                    }
                    else if (this.current_focused_control.Name == "inline_problem_date" && (this.form_mode == FORM_MODE.ADD_ITEM || this.form_mode == FORM_MODE.EDIT_ITEM))
                    {
                        Control[] ct = this.dgvProblem.Parent.Controls.Find("inline_problem_date", true);
                        if (ct.Length > 0)
                        {
                            CustomDateTimePicker dt = (CustomDateTimePicker)ct[0];
                            dt.dateTimePicker1.Focus();
                            SendKeys.Send("{F4}");
                            return true;
                        }
                    }
                    else if (this.current_focused_control.Name == "inline_problem_probcod" && (this.form_mode == FORM_MODE.ADD_ITEM || this.form_mode == FORM_MODE.EDIT_ITEM))
                    {
                        Control[] ct = this.dgvProblem.Parent.Controls.Find("inline_problem_probcod", true);
                        if (ct.Length > 0)
                        {
                            CustomTextBox probcod = (CustomTextBox)ct[0];
                            probcod.Focus();
                            IstabList wind = new IstabList(this.main_form, probcod.Texts, Istab.TABTYP.PROBLEM_CODE);
                            if (wind.ShowDialog() == DialogResult.OK)
                            {
                                probcod.Texts = wind.istab.typcod;
                                SendKeys.Send("{TAB}");
                            }
                            return true;
                        }
                    }
                }
            }
            if (keyData == Keys.PageUp)
            {
                if (this.form_mode == FORM_MODE.READ)
                {
                    this.toolStripPrevious.PerformClick();
                    return true;
                }
            }
            if (keyData == Keys.PageDown)
            {
                if (this.form_mode == FORM_MODE.READ)
                {
                    this.toolStripNext.PerformClick();
                    return true;
                }
            }
            if (keyData == (Keys.Control | Keys.Home))
            {
                this.toolStripFirst.PerformClick();
                return true;
            }
            if (keyData == (Keys.Control | Keys.End))
            {
                this.toolStripLast.PerformClick();
                return true;
            }
            if (keyData == Keys.F3)
            {
                if (this.form_mode == FORM_MODE.READ)
                {
                    this.tabControl1.SelectedTab = this.tabPage1;
                    return true;
                }
            }
            if (keyData == Keys.F4)
            {
                if (this.form_mode == FORM_MODE.READ)
                {
                    this.tabControl1.SelectedTab = this.tabPage2;
                    return true;
                }
            }
            if (keyData == Keys.F5)
            {
                this.toolStripReload.PerformClick();
                return true;
            }
            if (keyData == Keys.F8)
            {
                this.toolStripItem.PerformClick();
                return true;
            }
            if (keyData == Keys.F9)
            {
                this.toolStripSave.PerformClick();
                return true;
            }
            if (keyData == (Keys.Alt | Keys.D))
            {
                if (this.form_mode == FORM_MODE.READ_ITEM)
                {
                    this.deleteProblemData();
                    return true;
                }
                else
                {
                    this.toolStripDelete.PerformClick();
                    return true;
                }
            }
            if (keyData == (Keys.Control | Keys.L))
            {
                this.toolStripInquiryAll.PerformClick();
                return true;
            }
            if (keyData == (Keys.Alt | Keys.L))
            {
                this.toolStripInquiryRest.PerformClick();
                return true;
            }
            if (keyData == (Keys.Alt | Keys.S))
            {
                this.toolStripSearchSN.PerformClick();
                return true;
            }
            if (keyData == (Keys.Alt | Keys.D2))
            {
                this.toolStripSearchContact.PerformClick();
                return true;
            }
            if (keyData == (Keys.Alt | Keys.D3))
            {
                this.toolStripSearchCompany.PerformClick();
                return true;
            }
            if (keyData == (Keys.Alt | Keys.D4))
            {
                this.toolStripSearchDealer.PerformClick();
                return true;
            }
            if (keyData == (Keys.Alt | Keys.D5))
            {
                this.toolStripSearchOldnum.PerformClick();
                return true;
            }
            if (keyData == (Keys.Alt | Keys.D6))
            {
                this.toolStripSearchBusityp.PerformClick();
                return true;
            }
            if (keyData == (Keys.Alt | Keys.D7))
            {
                this.toolStripSearchArea.PerformClick();
                return true;
            }
            if (keyData == Keys.F2)
            {
                this.btnSupportNote.PerformClick();
                return true;
            }
            if (keyData == (Keys.Control | Keys.Alt | Keys.M))
            {
                //MessageBox.Show("Control + Alt. + M");
                this.toolStripInquiryMA.PerformClick();
            }
            if (keyData == (Keys.Control | Keys.Alt | Keys.C))
            {
                //MessageBox.Show("Control + Alt. + C");
                this.toolStripInquiryCloud.PerformClick();
            }

            return base.ProcessCmdKey(ref msg, keyData);
        }