示例#1
0
        void MenuEvents(int menuId)
        {
            try
            {
                switch (menuId)
                {

                    case (int)MenuItems.ExitMenu:
                        {
                            if (Program.Default.EnableExit == 1)
                                Application.Exit(); 
                            break;
                        }
                    case (int)MenuItems.ViewProductMenu:
                        {
                            
                            BTPrintClass.PrintClass.CheckForClear();
                            ActionsClass.Action.OpenProducts();
                            ActionsClass.Action.OpenScanned();
                            using (ViewProductForm frm = new ViewProductForm())
                            {
                                //this.Visible = false;
                                frm.ShowDialog();
                            }
                            ActionsClass.Action.CloseProducts();
                            ActionsClass.Action.ClosedScanned();
                            ActionsClass.Action.ClearCache();
                           // this.Visible = true;
                            //this.Activate();
                            break;
                        }
                    case (int)MenuItems.InventarMenu:
                        {
                            
                            BTPrintClass.PrintClass.CheckForClear();
                            ActionsClass.Action.OpenProducts();
                            ActionsClass.Action.OpenScanned();
                            using (InventarForm frm = new InventarForm())
                            {
                                //this.Visible = false;
                                frm.ShowDialog();
                            }
                            ActionsClass.Action.CloseProducts();
                            ActionsClass.Action.ClosedScanned();
                            ActionsClass.Action.ClearCache();
                            //this.Visible = true;
                            //this.Activate();
                            break;
                        }
                    case (int)MenuItems.SimpleIncome:
                        {

                            BTPrintClass.PrintClass.CheckForClear();
                            ActionsClass.Action.OpenProducts();
                            ActionsClass.Action.OpenScanned();
                            using (InventarForm frm = new InventarForm(InventarFormMode.SimpleIncome))
                            {
                                //this.Visible = false;
                                frm.ShowDialog();
                            }
                            ActionsClass.Action.CloseProducts();
                            ActionsClass.Action.ClosedScanned();
                            ActionsClass.Action.ClearCache();
                            //this.Visible = true;
                            //this.Activate();
                            break;
                        }
                    case (int)MenuItems.IncomeMenu:
                        {
                            //this.Visible = false;
                            BTPrintClass.PrintClass.CheckForClear();
                            ActionsClass.Action.OpenProducts();
                            ActionsClass.Action.OpenScanned();
                            using (
                                IncomeForm frm = new IncomeForm())
                            {
                                frm.ShowDialog();
                            }
                            ActionsClass.Action.CloseProducts();
                            ActionsClass.Action.ClosedScanned();
                            ActionsClass.Action.ClearCache();
                            //this.Visible = true;
                            //this.Activate();
                            //BTPrintClass.PrintClass.SetStatusEvent("Form Closed");
                            break;
                        }
                    case (int)MenuItems.TTNForm:
                        {

                            //this.Visible = false;


                            //thread = new System.Threading.Thread(
                            //    new System.Threading.ThreadStart(
                            //        frm_onBeginLoad));
                            //thread.IsBackground = false;


                            //thread.Start();

                            using (TtnForm frm = new TtnForm())
                            {
                                frm.onEndLoad += new EndLoadDelegate(frm_onEndLoad);
                                BTPrintClass.PrintClass.CheckForClear();
                                ActionsClass.Action.OpenProducts();
                                ActionsClass.Action.OpenScanned();
                                //this.Visible = false;
                                frm.ShowDialog();
                               //this.Visible = true;
                            }
                            ActionsClass.Action.CloseProducts();
                            ActionsClass.Action.ClosedScanned();
                            ActionsClass.Action.ClearCache();
                            //this.Visible = true;
                            //this.Activate();
                            break;

                        }
                    case (int)MenuItems.ReturnBoxes:
                        {

                            //this.Visible = false;


                            //thread = new System.Threading.Thread(
                            //    new System.Threading.ThreadStart(
                            //        frm_onBeginLoad));
                            //thread.IsBackground = false;


                            //thread.Start();

                            using (ReturnForm frm = new ReturnForm())
                            {
                                frm.onEndLoad += new EndLoadDelegate(frm_onEndLoad);
                                BTPrintClass.PrintClass.CheckForClear();
                                ActionsClass.Action.OpenProducts();
                                ActionsClass.Action.OpenScanned();
                                //this.Visible = false;
                                frm.ShowDialog();
                                //this.Visible = true;
                            }
                            ActionsClass.Action.CloseProducts();
                            ActionsClass.Action.ClosedScanned();
                            ActionsClass.Action.ClearCache();
                            //this.Visible = true;
                            //this.Activate();
                            break;

                        }
                    case (int)MenuItems.ViewSettingMenu:
                        {
                            BTPrintClass.PrintClass.CheckForClear();
                            using (SettingsForm frm = new SettingsForm())
                            {
                                //this.Visible = false;
                                frm.ShowDialog();
                            }
                           // this.Visible = true;
                            //this.Activate();
                            break;
                        }


                    default:
                        {
                            break;
                        }

                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message
                    , "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
            this.Refresh();
            BTPrintClass.PrintClass.SetStatusEvent("Main Form Refreshed");
        }
示例#2
0
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                //BTPrintClass.PrintClass.SetStatusEvent("KeyDown pressed");
                //this.textBox1.Text = e.KeyValue.ToString();
                //this.textBox1.Text = e.KeyCode.ToString();
                if (e.KeyCode == Keys.Enter)
                {
                    if (textBox1.Text != string.Empty)
                        OnScanned(textBox1.Text);

                    return;
                }
                if (e.KeyCode == Keys.Escape)
                {
                    this.Close();
                    return;
                }
                if (e.KeyValue == (int)SpecialButton.RedBtn)
                {
                    if (!closedCar && currentTtnBarcode != string.Empty)
                    {
                        enableScan = false;
                        ScanClass.Scaner.OnScanned -= scannedDelegate;
                        try
                        {
                            using (IncomeForm income =
                                new IncomeForm(TtnStruct, currentTtnBarcode))
                            {

                                income.ShowDialog();
                            }
                        }
                        finally
                        {
                            enableScan = true;
                            ScanClass.Scaner.InitScan();
                            ScanClass.Scaner.OnScanned += scannedDelegate;
                        }
                        CheckStatus(currentTtnBarcode);
                    }
                    return;
                }
                if (e.KeyValue == (int)SpecialButton.BlueBtn)
                {

                    return;
                }
                if (e.KeyValue == (int)SpecialButton.YellowBtn)
                {
                    enableScan = false;
                    try
                    {
                        if (currentTtnBarcode != string.Empty &&
                            Boxrows != null &&
                            Boxrows.Count > 0)
                        {

                            using (ViewTtnForm vFrm = new ViewTtnForm(TtnStruct))
                            {
                                vFrm.ShowDialog();
                            }
                        }

                    }
                    finally
                    {
                        enableScan = true;
                    }

                    /*int totals=0;
                    int totalBk=0;
                    ActionsClass.Action.CalculateTotalsWOPriority(
                        TSDUtils.ActionCode.IncomeBox,
                        DateTime.Today,
                        out totalBk,
                        out totals);
                    try
                    {
                        ScanClass.Scaner.OnScanned -= scannedDelegate;
                        using (DialogForm dlgfrm =
                                    new DialogForm(
                                        string.Format("За {0} отсканировано",
                                        DateTime.Today.ToString("dd.MM.yyyy"))
                                        , string.Format(" {0} правильных коробов", totalBk)
                                        , ""
                                        , "Подсчет коробов"))
                        {
                            dlgfrm.ShowDialog();
                        }
                    }
                    finally
                    {
                        ScanClass.Scaner.OnScanned += scannedDelegate;

                    }
                     * */

                    return;
                }
                if (e.KeyValue == (int)SpecialButton.GreenBtn) //GreenBtn
                {

                    return;
                }

            }
            finally
            {
                this.Refresh();
            }
        }