Exemplo n.º 1
0
        /// <summary>
        /// Обробляє виконання операцій відповідно до того, який пункт меню був вибраний
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Menu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (_fl_menuIsActive || e.ClickedItem.Tag == null)
                return;

            _fl_menuIsActive = true;
            switch (e.ClickedItem.Tag.ToString())
            {
                #region Main
                case "fiscalFunctions":
                    {
                        uiWndFiscalFunctions ff = new uiWndFiscalFunctions(Program.AppPlugins.GetActive<IFPDriver>().Name, Program.AppPlugins.GetActive<IFPDriver>().AllowedMethods);
                        try
                        {
                            if (ff.ShowDialog(this) == DialogResult.OK)
                                Program.AppPlugins.GetActive<IFPDriver>().CallFunction(ff.Function);
                        }
                        catch (Exception ex)
                        {
                            MMessageBoxEx.Show(this.chequeDGV, ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        ff.Dispose();
                        break;
                    }
                case "LastDBChanges":
                    {
                        this.timerExchangeImport_Tick(this.timerExchangeImport, EventArgs.Empty);
                        /*uiWndBaseChanges DBChanges = new uiWndBaseChanges();
                        if (DBChanges.ShowDialog() == DialogResult.OK)
                            timer1_Tick(timer1, EventArgs.Empty);
                        DBChanges.Dispose();
                        */
                        break;
                    }
                case "Administrator":
                    {
                        DialogResult rez = DialogResult.None;
                        if (_fl_adminMode)
                            rez = MMessageBoxEx.Show(this.chequeDGV, "Вийти з режиму адміністратора", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        else
                            rez = admin.ShowDialog();

                        switch (rez)
                        {
                            case DialogResult.OK:
                                _fl_adminMode = true;
                                break;
                            case DialogResult.Yes:
                                _fl_adminMode = false;
                                break;
                        }

                        RefershMenus();
                        break;
                    }
                case "UnitFilter":
                    {
                        if (_fl_adminMode || admin.ShowDialog() == DialogResult.OK)
                        {
                            uiWndUnitFilter fl = new uiWndUnitFilter(Articles);
                            fl.ShowDialog();
                            fl.Dispose();
                        }
                        break;
                    }
                case "ChequeFormat":
                    {
                        uiWndDiscountSettings billRul = new uiWndDiscountSettings();
                        billRul.ShowDialog();
                        billRul.Dispose();
                        ResetDiscount();
                        UpdateSumInfo(true);
                        break;
                    }
                case "Invent":
                    {
                        if (Cheque.Rows.Count != 0 && !_fl_isInvenCheque)
                            return;
                        _fl_isInvenCheque = !_fl_isInvenCheque;
                        if (_fl_isInvenCheque)
                        {
                            DataTable dTable = new DataTable();
                            DataSet dSet = new DataSet();
                            if (ConfigManager.Instance.CommonConfiguration.PROFILES_UseProfiles)
                            {
                                dSet = DataWorkCheque.OpenInvent(this.Cheques);
                                this.Cheques.Tables.Clear();
                                foreach (DataTable dt in dSet.Tables)
                                {
                                    this.Cheques.Tables.Add(dt.Copy());
                                    dTable.Merge(dt.Copy());
                                }
                            }
                            else
                                dTable = DataWorkCheque.OpenInvent();

                            if (dTable != null)
                            {
                                dTable.ExtendedProperties.Add("loading", true);
                                Cheque.Merge(dTable);
                                Cheque.ExtendedProperties.Remove("loading");
                                dTable.ExtendedProperties.Remove("loading");
                            }
                            else
                                _fl_isInvenCheque = false;
                        }
                        else
                        {
                            DataWorkCheque.SaveInvent(Cheque, false, this.Cheques);
                            //Cheque.Rows.Clear();
                            //UpdateSumDisplay(true, true);
                            RowsRemoved_MyEvent(true, true, true);
                        }

                        RefershMenus();
                        RefreshChequeInformer(true);
                        інвентаризаціяToolStripMenuItem.Checked = _fl_isInvenCheque;
                        break;
                    }
                case "RetriveCheque":
                    {
                        _fl_isReturnCheque = !_fl_isReturnCheque;
                        чекПоверненняToolStripMenuItem.Checked = _fl_isReturnCheque;
                        RefreshChequeInformer(true);
                        break;
                    }
                case "Settings":
                    {
                        uiWndSettings set = new uiWndSettings();
                        if (set.ShowDialog() == DialogResult.OK)
                        {
                            RefreshComponents(false);
                            UpdateMyControls();
                            SearchFilter(false, ConfigManager.Instance.CommonConfiguration.APP_SearchType, true);
                            this.Text = string.Format("{2}{1}{0}", Application.ProductName, " - ", ConfigManager.Instance.CommonConfiguration.APP_SubUnitName);
                        }
                        set.Dispose();
                        break;
                    }
                case "PrintingSettings":
                    {
                        uiWndPrinting pSet = new uiWndPrinting();
                        pSet.ShowDialog();
                        pSet.Dispose();
                        break;
                    }
                case "Registration":
                    {
                        uiWndRegistration rf = new uiWndRegistration();
                        if (rf.ShowDialog() == DialogResult.OK)
                            MMessageBoxEx.Show(this.chequeDGV, "Перезавантажте програму для продовження реєстрації", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        rf.Dispose();
                        break;
                    }
                case "AboutApp":
                    {
                        uiWndAboutBox abox = new uiWndAboutBox();
                        abox.ShowDialog();
                        abox.Dispose();
                        break;
                    }
                case "ChangeCashier":
                    {
                        DialogResult = DialogResult.Retry;
                        Close();
                        break;
                    }
                case "Exit":
                    {
                        DialogResult = DialogResult.Cancel;
                        Close();
                        break;
                    }
                #endregion
                #region TablesView
                case "Vertical":
                    {
                        if (!((ToolStripMenuItem)e.ClickedItem).Checked)
                        {
                            splitContainer1.Orientation = Orientation.Vertical;
                            ConfigManager.Instance.CommonConfiguration.STYLE_SplitOrient = Orientation.Vertical;
                            splitContainer1.SplitterDistance = splitContainer1.Width / 2;
                        }
                        else
                        {
                            splitContainer1.Orientation = Orientation.Horizontal;
                            ConfigManager.Instance.CommonConfiguration.STYLE_SplitOrient = Orientation.Horizontal;
                            splitContainer1.SplitterDistance = splitContainer1.Height / 2;
                        }
                        RefreshWindowMenu();
                        break;
                    }
                case "ArticleWindow":
                    {
                        splitContainer1.Panel2Collapsed = !splitContainer1.Panel2Collapsed;
                        ConfigManager.Instance.CommonConfiguration.STYLE_ArtSideCollapsed = !ConfigManager.Instance.CommonConfiguration.STYLE_ArtSideCollapsed;
                        RefreshWindowMenu();
                        break;
                    }
                case "SensorType":
                    {
                        if (!((ToolStripMenuItem)e.ClickedItem).Checked)
                        {/*
                            if (splitContainer1.Orientation != Orientation.Vertical)
                            {
                                splitContainer1.Tag = "R";
                            }*/
                            //splitContainer1.Orientation = Orientation.Vertical;
                            //AppConfig.STYLE_SplitOrient = Orientation.Vertical;
                            //RefreshWindowMenu();
                            //splitContainer1.SplitterDistance = splitContainer1.Width / 2;

                            this.sensorDataPanel1.Navigator.SetAndShowNavigator(ApplicationConfiguration.Instance.GetValueByKey<Hashtable>("productFiltering"));

                            this.sensorDataPanel1.Visible = true;
                            this.chequeContainer.Panel2Collapsed = false;

                            /*
                            if (this.sensorPanel1.SensorType == 50 && ConfigManager.Instance.CommonConfiguration.skin_sensor_splitter_chq_50 < this.chequeContainer.Height && this.chequeContainer.Height * 2 / 3 > ConfigManager.Instance.CommonConfiguration.skin_sensor_splitter_chq_50)
                                this.chequeContainer.SplitterDistance = ConfigManager.Instance.CommonConfiguration.skin_sensor_splitter_chq_50;
                            else if (this.sensorPanel1.SensorType == 100 && ConfigManager.Instance.CommonConfiguration.skin_sensor_splitter_chq_100 < this.chequeContainer.Height && this.chequeContainer.Height * 2 / 3 > ConfigManager.Instance.CommonConfiguration.skin_sensor_splitter_chq_100)
                                this.chequeContainer.SplitterDistance = ConfigManager.Instance.CommonConfiguration.skin_sensor_splitter_chq_100;
                            else
                                this.chequeContainer.SplitterDistance = this.chequeContainer.Height * 2 / 3;

                            */
                            this.articleDGV.Parent = this.sensorDataPanel1.Placeholder;
                            //this.articleDGV.BringToFront();

                            RefreshComponents(true);

                            //-Sensor_EventHandler(null);

                            //this.TopMost = true;
                            //System.Diagnostics.Process.Start("vk.exe");

                            //enabling dependence menu
                            управліннToolStripMenuItem.Enabled = true;
                        }
                        else
                        {/*
                            if (splitContainer1.Tag != null && splitContainer1.Tag.ToString() == "R")
                            {
                                splitContainer1.Orientation = Orientation.Horizontal;
                                ConfigManager.Instance.CommonConfiguration.STYLE_SplitOrient = Orientation.Horizontal;
                                RefreshWindowMenu();
                                splitContainer1.SplitterDistance = splitContainer1.Height / 2;
                            }*/

                            this.sensorDataPanel1.Visible = false;
                            this.chequeContainer.Panel2Collapsed = true;

                            this.articleDGV.Parent = this.splitContainer1.Panel2;

                            //this.TopMost = false;
                            управліннToolStripMenuItem.Enabled = false;
                        }
                        break;
                    }
                case "SensorType_Components_ChqNav":
                    {
                        this.sensorPanel1.ShowComponent(SensorUgcPanel.SensorComponents.Scrolling, !((ToolStripMenuItem)e.ClickedItem).Checked);
                        break;
                    }
                case "SensorType_Components_ChqOpr":
                    {
                        this.sensorPanel1.ShowComponent(SensorUgcPanel.SensorComponents.Operations, !((ToolStripMenuItem)e.ClickedItem).Checked);
                        break;
                    }
                case "SensorType_Components_ChqSrch":
                    {
                        this.sensorPanel1.ShowComponent(SensorUgcPanel.SensorComponents.Search, !((ToolStripMenuItem)e.ClickedItem).Checked);
                        break;
                    }
                case "SensorType_Components_ChqBills":
                    {
                        this.sensorPanel1.ShowComponent(SensorUgcPanel.SensorComponents.Additional, !((ToolStripMenuItem)e.ClickedItem).Checked);
                        break;
                    }
                case "SensorType_VK":
                    {
                        if (сенсорToolStripMenuItem.Checked)
                            System.Diagnostics.Process.Start("vk.bat");
                        break;
                    }
                case "SensorType_Components_ChqIsVertical":
                    {
                        if (!((ToolStripMenuItem)e.ClickedItem).Checked)
                            this.chequeContainer.Orientation = Orientation.Vertical;
                        else
                            this.chequeContainer.Orientation = Orientation.Horizontal;
                        break;
                    }
                case "SensorType_Components_ArtNav":
                    {
                        this.sensorDataPanel1.Container.Panel1Collapsed = ((ToolStripMenuItem)e.ClickedItem).Checked;
                        //tableLayoutPanel1.Visible = !((ToolStripMenuItem)e.ClickedItem).Checked;
                        //sensor_breadcrumb_container.Visible = !((ToolStripMenuItem)e.ClickedItem).Checked;
                        break;
                    }
                case "SensorType_Components_ArtScroll":
                    {
                        this.sensorDataPanel1.Scroller.Visible = !((ToolStripMenuItem)e.ClickedItem).Checked;
                        break;
                    }
                #endregion
                #region Bills
                case "BillManager": // lock bill forever
                    {
                        if (new uiWndAdmin().ShowDialog(this) != DialogResult.OK)
                            break;
                        uiWndBillManagercs bm = new uiWndBillManagercs();
                        bm.ShowDialog(this);
                        bm.Dispose();
                        break;
                    }
                case "ResetBill": // lock bill forever
                    {
                        int changeState = DataWorkBill.BillWasChanged(ConfigManager.Instance.CommonConfiguration.Path_Bills, this.PD_Order);
                        switch (changeState)
                        {
                            case 1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Були внесені змінити в поточний рахунок\r\nПерезавантажте рахунок за допомогою меню або натисніть ALT+R", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    break;
                                }
                            case 2:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок вже закритий\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                            case -1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок видалений з бази\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                        }
                        if (changeState != 0)
                            break;

                        if ((bool)DataWorkShared.ExtractBillProperty(this.Cheque, CoreConst.IS_LOCKED, false))
                        {
                            MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок № " + DataWorkShared.ExtractBillProperty(this.Cheque, CoreConst.BILL_NO) + " надрукований клієнту.\r\nЗробіть з нього чек.",
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            break;//r
                        }
                        /*
                        if (new uiWndAdmin().ShowDialog(this) != DialogResult.OK)
                            break;
                        */

                        if (DialogResult.Yes != MMessageBoxEx.Show(this.chequeDGV, "Анулювати поточний рахунок № " + DataWorkShared.ExtractBillProperty(this.Cheque, CoreConst.BILL_NO),
                            Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                            break;
                        //CoreLib.LockBill(Cheque, "null");
                        string billNo = DataWorkShared.ExtractBillProperty(this.PD_Order, CoreConst.BILL_NO, string.Empty, false).ToString();
                        DataWorkBill.LockBill(this.PD_Order, "null");
                        RowsRemoved_MyEvent(true, true, true);
                        this.RefershMenus();
                        //this.addBillInfo.Text = string.Format("{0} {1}", "Рахунок №", billNo);
                        break;
                    }
                case "SaveAndPrintAndClose": // save, print and close
                    {
                        if (_fl_isInvenCheque)
                            break;

                        int changeState = DataWorkBill.BillWasChanged(ConfigManager.Instance.CommonConfiguration.Path_Bills, this.PD_Order);
                        switch (changeState)
                        {
                            case 1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Були внесені змінити в поточний рахунок\r\nПерезавантажте рахунок за допомогою меню або натисніть ALT+R", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    break;
                                }
                            case 2:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок вже закритий\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                            case -1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок видалений з бази\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                        }
                        if (changeState != 0)
                            break;

                        uiWndBillSave bs = new uiWndBillSave(this.PD_Order);
                        bs.ShowDialog();

                        if (bs.DialogResult == DialogResult.OK)
                        {
                            //if (bs.IsNewBill)
                            //this.addBillInfo.Text = string.Format("{0} {1}", "ЗБЕРЕЖЕНИЙ РАХ.№", bs.GetNewBillNo);
                            //else
                            //    this.addBillInfo.Text = "";
                            uiWndBillPrint bPrn = new uiWndBillPrint(bs.SavedBill);
                            if (bPrn.ShowDialog(this) == DialogResult.OK)
                            {
                                this.RefershMenus();
                            }
                            bPrn.Dispose();
                            addChequeInfo.Text = string.Empty;
                            RowsRemoved_MyEvent(true, true, true);
                            //this.addBillInfo.Text = string.Format("{0} {1}", "Рахунок №", bs.GetNewBillNo);
                        }
                        bs.Dispose();
                        break;
                    }
                case "SaveAndPrint": // save, print but leave opened
                    {
                        if (_fl_isInvenCheque)
                            break;

                        int changeState = DataWorkBill.BillWasChanged(ConfigManager.Instance.CommonConfiguration.Path_Bills, this.PD_Order);
                        switch (changeState)
                        {
                            case 1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Були внесені змінити в поточний рахунок\r\nПерезавантажте рахунок за допомогою меню або натисніть ALT+R", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    break;
                                }
                            case 2:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок вже закритий\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                            case -1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок видалений з бази\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                        }
                        if (changeState != 0)
                            break;

                        uiWndBillSave bs = new uiWndBillSave(this.PD_Order);
                        if (bs.ShowDialog() == DialogResult.OK)
                        {
                            this.addBillInfo.Text = string.Format("{0} {1}", "Рахунок №", bs.GetNewBillNo);
                            uiWndBillPrint bPrn = new uiWndBillPrint(bs.SavedBill);
                            if (bPrn.ShowDialog(this) == DialogResult.OK)
                            {
                                this.RefershMenus();
                            }
                            bPrn.Dispose();
                            //DataWorkShared.MergeDataTableProperties(ref this.Cheque, bs.SavedBill);
                            Cheque.Merge(bs.SavedBill);
                            this.RefershMenus();
                        }
                        bs.Dispose();
                        break;
                    }
                case "SaveAndClose": // save and close
                    {
                        if (_fl_isInvenCheque)
                            break;

                        int changeState = DataWorkBill.BillWasChanged(ConfigManager.Instance.CommonConfiguration.Path_Bills, this.PD_Order);
                        switch (changeState)
                        {
                            case 1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Були внесені змінити в поточний рахунок\r\nПерезавантажте рахунок за допомогою меню або натисніть ALT+R", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    break;
                                }
                            case 2:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок вже закритий\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                            case -1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок видалений з бази\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                        }
                        if (changeState != 0)
                            break;

                        /*for (int i = 0; i < 200; i++)
                        {
                            DataTable _testDT = this.PD_Order.Copy();
                            DataWorkBill.SaveBill(true, i.ToString().PadLeft(4, '0'), "DEMO TEST", ref _testDT);
                        }*/
                        uiWndBillSave bs = new uiWndBillSave(this.PD_Order);
                        if (bs.ShowDialog() == DialogResult.OK)
                        {
                            addChequeInfo.Text = string.Empty;
                            RowsRemoved_MyEvent(true, true, true);
                            // if (bs.IsNewBill)
                            // ------ this.addBillInfo.Text = string.Format("{0} {1}", "ЗБЕРЕЖЕНИЙ РАХ.№", bs.GetNewBillNo);
                            //else
                            //this.addBillInfo.Text = "";
                        }
                        bs.Dispose();
                        break;
                    }
                case "AllBills": // show bill manager
                    {
                        string currentBillNumber = DataWorkShared.ExtractBillProperty(this.Cheque, CoreConst.BILL_NO).ToString();
                        /*
                            if (this.Cheque.ExtendedProperties["NOM"] != null)
                                currentBillNumber = this.Cheque.ExtendedProperties["NOM"].ToString();
                        */
                        //if ()
                        uiWndBillList bl = new uiWndBillList(currentBillNumber);
                        if (bl.ShowDialog() == DialogResult.OK)
                            if (Cheque.Rows.Count == 0)
                            {
                                Cheque.Merge(bl.LoadedBill);
                                this.UpdateDiscountValues(this.Cheque);
                                this.addBillInfo.Text = string.Format("{0} {1}", "Рахунок №", DataWorkShared.ExtractBillProperty(this.Cheque, CoreConst.BILL_NO));
                                UpdateSumInfo(true);
                            }
                            else MMessageBoxEx.Show(this.chequeDGV, "Неможливо відкрити рахунок\nТаблиця чеку не є порожня", Application.ProductName,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                        bl.Dispose();
                        break;
                    }
                case "PrintBill": // removed
                    {
                        int changeState = DataWorkBill.BillWasChanged(ConfigManager.Instance.CommonConfiguration.Path_Bills, this.PD_Order);
                        switch (changeState)
                        {
                            case 1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Були внесені змінити в поточний рахунок\r\nПерезавантажте рахунок за допомогою меню або натисніть ALT+R", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    break;
                                }
                            case 2:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок вже закритий\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                            case -1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок видалений з бази\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                        }
                        if (changeState != 0)
                            break;

                        uiWndBillPrint bPrn = new uiWndBillPrint(this.PD_Order);
                        bPrn.ShowDialog(this);
                        bPrn.Dispose();
                        break;
                    }
                case "SaveChangeComment":
                    {
                        if (_fl_isInvenCheque)
                            break;

                        int changeState = DataWorkBill.BillWasChanged(ConfigManager.Instance.CommonConfiguration.Path_Bills, this.PD_Order);
                        switch (changeState)
                        {
                            case 1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Були внесені змінити в поточний рахунок\r\nПерезавантажте рахунок за допомогою меню або натисніть ALT+R", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    break;
                                }
                            case 2:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок вже закритий\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                            case -1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок видалений з бази\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                        }
                        if (changeState != 0)
                            break;

                        uiWndBillSave bs = new uiWndBillSave(this.PD_Order);
                        bs.UpdateComment = true;
                        if (bs.ShowDialog() == DialogResult.OK)
                        {
                            //if (bs.IsNewBill)
                            this.addBillInfo.Text = string.Format("{0} {1}", "Рахунок №", bs.GetNewBillNo);
                            //this.PD_Order = bs.SavedBill;
                            // else
                            //    this.addBillInfo.Text = "";

                            DataWorkShared.MergeDataTableProperties(ref this.Cheque, bs.SavedBill);

                            this.RefershMenus();

                        }
                        bs.Dispose();
                        break;
                    }
                case "SaveBill": // just save and leave opened
                    {
                        if (_fl_isInvenCheque)
                            break;

                        int changeState = DataWorkBill.BillWasChanged(ConfigManager.Instance.CommonConfiguration.Path_Bills, this.PD_Order);
                        switch (changeState)
                        {
                            case 1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Були внесені змінити в поточний рахунок\r\nПерезавантажте рахунок за допомогою меню або натисніть ALT+R", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    break;
                                }
                            case 2:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок вже закритий\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                            case -1:
                                {
                                    MMessageBoxEx.Show(this.chequeDGV, "Поточний рахунок видалений з бази\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                        }
                        if (changeState != 0)
                            break;

                        uiWndBillSave bs = new uiWndBillSave(this.PD_Order);
                        if (bs.ShowDialog() == DialogResult.OK)
                        {
                            //if (bs.IsNewBill)
                            this.addBillInfo.Text = string.Format("{0} {1}", "Рахунок №", bs.GetNewBillNo);
                            //this.PD_Order = bs.SavedBill;
                            // else
                            //    this.addBillInfo.Text = "";

                            DataWorkShared.MergeDataTableProperties(ref this.Cheque, bs.SavedBill);

                            this.RefershMenus();

                        }
                        bs.Dispose();
                        break;
                    }
                case "ReloadBill": // ReloadBill
                    {
                        object billName = DataWorkShared.ExtractBillProperty(this.PD_Order, CoreConst.PATH);
                        DataTable LoadedBill = DataWorkBill.LoadCombinedBill(ConfigManager.Instance.CommonConfiguration.Path_Bills + "\\" + billName.ToString());
                        RowsRemoved_MyEvent(true, true, true);
                        Cheque.Merge(LoadedBill);
                        this.addBillInfo.Text = string.Format("{0} {1}", "Рахунок №", DataWorkShared.ExtractBillProperty(this.Cheque, CoreConst.BILL_NO));
                        UpdateSumInfo(true);
                        break;
                    }
                case "CloseBillWithoutChanges": // CloseBill
                    {
                        addChequeInfo.Text = string.Empty;
                        RowsRemoved_MyEvent(true, true, true);
                        break;
                    }
                #endregion
                #region Plugins
                case "SendComPortCommand":
                    {
                        wndAdditional.uiWndAdditionalPortCommands cm = new wndAdditional.uiWndAdditionalPortCommands();
                        cm.ShowDialog();
                        cm.Dispose();
                        //MessageBox.Show(cm.PortCommand);
                        break;
                    }
                #endregion
            }

            _fl_menuIsActive = false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Обробляє виконання операцій відповідно до того, який пункт меню був вибраний
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Menu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (_fl_menuIsActive || e.ClickedItem.Tag == null)
                return;

            _fl_menuIsActive = true;
            switch (e.ClickedItem.Tag.ToString())
            {
                #region Main
                case "fiscalFunctions":
                    {
                        uiWndFiscalFunctions ff = new uiWndFiscalFunctions(Program.Service.ComPort.Tag, Program.Service.PublicFunctions);
                        try
                        {
                            if (ff.ShowDialog(this) == DialogResult.OK)
                                Program.Service.CallFunction(ff.Function, ff.Descriprion, null);
                        }
                        catch (Exception ex)
                        {
                            MMessageBox.Show(this, ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        ff.Dispose();
                        break;
                    }
                case "LastDBChanges":
                    {
                        uiWndBaseChanges DBChanges = new uiWndBaseChanges();
                        if (DBChanges.ShowDialog() == DialogResult.OK)
                            timer1_Tick(timer1, EventArgs.Empty);
                        DBChanges.Dispose();
                        break;
                    }
                case "Administrator":
                    {
                        DialogResult rez = DialogResult.None;
                        if (ADMIN_STATE)
                            rez = MMessageBox.Show(this, "Вийти з режиму адміністратора", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        else
                            rez = admin.ShowDialog();

                        switch (rez)
                        {
                            case DialogResult.OK:
                                ADMIN_STATE = true;
                                break;
                            case DialogResult.Yes:
                                ADMIN_STATE = false;
                                break;
                        }

                        RefershMenus();
                        break;
                    }
                case "UnitFilter":
                    {
                        uiWndUnitFilter fl = new uiWndUnitFilter(Articles);
                        fl.ShowDialog();
                        fl.Dispose();
                        break;
                    }
                case "ChequeFormat":
                    {
                        uiWndDiscountSettings billRul = new uiWndDiscountSettings();
                        billRul.ShowDialog();
                        billRul.Dispose();
                        ResetDiscount();
                        UpdateSumInfo(true);
                        break;
                    }
                case "Invent":
                    {
                        if (Cheque.Rows.Count != 0 && !inventChq)
                            return;
                        inventChq = !inventChq;
                        if (inventChq)
                        {
                            DataTable dTable = CoreLib.OpenInvent();
                            if (dTable != null)
                            {
                                dTable.ExtendedProperties.Add("loading", true);
                                Cheque.Merge(dTable);
                                Cheque.ExtendedProperties.Remove("loading");
                                dTable.ExtendedProperties.Remove("loading");
                            }
                            else
                                inventChq = false;
                        }
                        else
                        {
                            CoreLib.SaveInvent(Cheque, false);
                            Cheque.Rows.Clear();
                        }

                        RefershMenus();
                        RefreshChequeInformer(true);
                        інвентаризаціяToolStripMenuItem.Checked = inventChq;
                        break;
                    }
                case "RetriveCheque":
                    {
                        retriveChq = !retriveChq;
                        чекПоверненняToolStripMenuItem.Checked = retriveChq;
                        RefreshChequeInformer(true);
                        break;
                    }
                case "Settings":
                    {
                        uiWndSettings set = new uiWndSettings();
                        if (set.ShowDialog() == DialogResult.OK)
                        {
                            UpdateMyControls();
                            SearchFilter(false, AppConfig.APP_SearchType, true);
                            this.Text = string.Format("{2}{1}{0}", Application.ProductName, " - ", AppConfig.APP_SubUnitName);
                        }
                        set.Dispose();
                        break;
                    }
                case "PrintingSettings":
                    {
                        uiWndPrinting pSet = new uiWndPrinting();
                        pSet.ShowDialog();
                        pSet.Dispose();
                        break;
                    }
                case "Registration":
                    {
                        uiWndRegistration rf = new uiWndRegistration();
                        if (rf.ShowDialog() == DialogResult.OK)
                            MMessageBox.Show(this, "Перезавантажте програму для продовження реєстрації", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        rf.Dispose();
                        break;
                    }
                case "AboutApp":
                    {
                        uiWndAboutBox abox = new uiWndAboutBox();
                        abox.ShowDialog();
                        abox.Dispose();
                        break;
                    }
                case "ChangeCashier":
                    {
                        DialogResult = DialogResult.Retry;
                        Close();
                        break;
                    }
                case "Exit":
                    {
                        DialogResult = DialogResult.Cancel;
                        Close();
                        break;
                    }
                #endregion
                #region TablesView
                case "Horizontal":
                    {
                        splitContainer1.Orientation = Orientation.Horizontal;
                        AppConfig.STYLE_SplitOrient = Orientation.Horizontal;
                        RefreshWindowMenu();
                        break;
                    }
                case "Vertical":
                    {
                        splitContainer1.Orientation = Orientation.Vertical;
                        AppConfig.STYLE_SplitOrient = Orientation.Vertical;
                        RefreshWindowMenu();
                        break;
                    }
                case "ArticleWindow":
                    {
                        splitContainer1.Panel2Collapsed = !splitContainer1.Panel2Collapsed;
                        AppConfig.STYLE_ArtSideCollapsed = !AppConfig.STYLE_ArtSideCollapsed;
                        RefreshWindowMenu();
                        break;
                    }
                #endregion
                #region Bills
                case "BillManager": // lock bill forever
                    {
                        if (new uiWndAdmin().ShowDialog(this) != DialogResult.OK)
                            break;
                        uiWndBillManagercs bm = new uiWndBillManagercs();
                        bm.ShowDialog(this);
                        bm.Dispose();
                        break;
                    }
                case "ResetBill": // lock bill forever
                    {
                        int changeState = DataWorkBill.BillWasChanged(AppConfig.Path_Bills, this.PD_Order);
                        switch (changeState)
                        {
                            case 1:
                                {
                                    MMessageBox.Show(this, "Були внесені змінити в поточний рахунок\r\nПерезавантажте рахунок за допомогою меню або натисніть ALT+R", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    break;
                                }
                            case 2:
                                {
                                    MMessageBox.Show(this, "Поточний рахунок вже закритий\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                            case -1:
                                {
                                    MMessageBox.Show(this, "Поточний рахунок видалений з бази\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                        }
                        if (changeState != 0)
                            break;

                        if ((bool)DataWorkShared.ExtractBillProperty(this.Cheque, CoreConst.IS_LOCKED, false))
                        {
                            MMessageBox.Show("Поточний рахунок № " + DataWorkShared.ExtractBillProperty(this.Cheque, CoreConst.BILL_NO) + " надрукований клієнту.\r\nЗробіть з нього чек.",
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            break;//r
                        }
                        /*
                        if (new uiWndAdmin().ShowDialog(this) != DialogResult.OK)
                            break;
                        */

                        if (DialogResult.Yes != MMessageBox.Show("Анулювати поточний рахунок № " + DataWorkShared.ExtractBillProperty(this.Cheque, CoreConst.BILL_NO),
                            Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                            break;
                        //CoreLib.LockBill(Cheque, "null");
                        string billNo = DataWorkShared.ExtractBillProperty(this.PD_Order, CoreConst.BILL_NO, string.Empty, false).ToString();
                        mdcore.Lib.DataWorkBill.LockBill(this.PD_Order, "null");
                        RowsRemoved_MyEvent(true, true);
                        this.RefershMenus();
                        //this.addBillInfo.Text = string.Format("{0} {1}", "Рахунок №", billNo);
                        break;
                    }
                case "SaveAndPrintAndClose": // save, print and close
                    {
                        if (inventChq)
                            break;

                        int changeState = DataWorkBill.BillWasChanged(AppConfig.Path_Bills, this.PD_Order);
                        switch (changeState)
                        {
                            case 1:
                                {
                                    MMessageBox.Show(this, "Були внесені змінити в поточний рахунок\r\nПерезавантажте рахунок за допомогою меню або натисніть ALT+R", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    break;
                                }
                            case 2:
                                {
                                    MMessageBox.Show(this, "Поточний рахунок вже закритий\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                            case -1:
                                {
                                    MMessageBox.Show(this, "Поточний рахунок видалений з бази\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                        }
                        if (changeState != 0)
                            break;

                        BillSave bs = new BillSave(this.PD_Order);
                        bs.ShowDialog();

                        if (bs.DialogResult == DialogResult.OK)
                        {
                            //if (bs.IsNewBill)
                            //this.addBillInfo.Text = string.Format("{0} {1}", "ЗБЕРЕЖЕНИЙ РАХ.№", bs.GetNewBillNo);
                            //else
                            //    this.addBillInfo.Text = "";
                            uiWndBillPrint bPrn = new uiWndBillPrint(bs.SavedBill);
                            if (bPrn.ShowDialog(this) == DialogResult.OK)
                            {
                                this.RefershMenus();
                            }
                            bPrn.Dispose();
                            RowsRemoved_MyEvent(true, true);
                            //this.addBillInfo.Text = string.Format("{0} {1}", "Рахунок №", bs.GetNewBillNo);
                        }
                        bs.Dispose();
                        break;
                    }
                case "SaveAndPrint": // save, print but leave opened
                    {
                        if (inventChq)
                            break;

                        int changeState = DataWorkBill.BillWasChanged(AppConfig.Path_Bills, this.PD_Order);
                        switch (changeState)
                        {
                            case 1:
                                {
                                    MMessageBox.Show(this, "Були внесені змінити в поточний рахунок\r\nПерезавантажте рахунок за допомогою меню або натисніть ALT+R", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    break;
                                }
                            case 2:
                                {
                                    MMessageBox.Show(this, "Поточний рахунок вже закритий\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                            case -1:
                                {
                                    MMessageBox.Show(this, "Поточний рахунок видалений з бази\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                        }
                        if (changeState != 0)
                            break;

                        BillSave bs = new BillSave(this.PD_Order);
                        if (bs.ShowDialog() == DialogResult.OK)
                        {
                            this.addBillInfo.Text = string.Format("{0} {1}", "Рахунок №", bs.GetNewBillNo);
                            uiWndBillPrint bPrn = new uiWndBillPrint(bs.SavedBill);
                            if (bPrn.ShowDialog(this) == DialogResult.OK)
                            {
                                this.RefershMenus();
                            }
                            bPrn.Dispose();
                            //DataWorkShared.MergeDataTableProperties(ref this.Cheque, bs.SavedBill);
                            Cheque.Merge(bs.SavedBill);
                            this.RefershMenus();
                        }
                        bs.Dispose();
                        break;
                    }
                case "SaveAndClose": // save and close
                    {
                        if (inventChq)
                            break;

                        int changeState = DataWorkBill.BillWasChanged(AppConfig.Path_Bills, this.PD_Order);
                        switch (changeState)
                        {
                            case 1:
                                {
                                    MMessageBox.Show(this, "Були внесені змінити в поточний рахунок\r\nПерезавантажте рахунок за допомогою меню або натисніть ALT+R", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    break;
                                }
                            case 2:
                                {
                                    MMessageBox.Show(this, "Поточний рахунок вже закритий\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                            case -1:
                                {
                                    MMessageBox.Show(this, "Поточний рахунок видалений з бази\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                        }
                        if (changeState != 0)
                            break;

                        BillSave bs = new BillSave(this.PD_Order);
                        if (bs.ShowDialog() == DialogResult.OK)
                        {
                            RowsRemoved_MyEvent(true, true);
                            // if (bs.IsNewBill)
                            // ------ this.addBillInfo.Text = string.Format("{0} {1}", "ЗБЕРЕЖЕНИЙ РАХ.№", bs.GetNewBillNo);
                            //else
                            //this.addBillInfo.Text = "";
                        }
                        bs.Dispose();
                        break;
                    }
                case "AllBills": // show bill manager
                    {
                        string currentBillNumber = DataWorkShared.ExtractBillProperty(this.Cheque, CoreConst.BILL_NO).ToString();
                        /*
                            if (this.Cheque.ExtendedProperties["NOM"] != null)
                                currentBillNumber = this.Cheque.ExtendedProperties["NOM"].ToString();
                        */
                        //if ()
                        BillsList bl = new BillsList(currentBillNumber);
                        if (bl.ShowDialog() == DialogResult.OK)
                            if (Cheque.Rows.Count == 0)
                            {
                                Cheque.Merge(bl.LoadedBill);
                                this.addBillInfo.Text = string.Format("{0} {1}", "Рахунок №", DataWorkShared.ExtractBillProperty(this.Cheque, mdcore.Common.CoreConst.BILL_NO));
                                UpdateSumInfo(true);
                            }
                            else MMessageBox.Show(this, "Неможливо відкрити рахунок\nТаблиця чеку не є порожня", Application.ProductName,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                        bl.Dispose();
                        break;
                    }
                case "PrintBill": // removed
                    {
                        int changeState = DataWorkBill.BillWasChanged(AppConfig.Path_Bills, this.PD_Order);
                        switch (changeState)
                        {
                            case 1:
                                {
                                    MMessageBox.Show(this, "Були внесені змінити в поточний рахунок\r\nПерезавантажте рахунок за допомогою меню або натисніть ALT+R", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    break;
                                }
                            case 2:
                                {
                                    MMessageBox.Show(this, "Поточний рахунок вже закритий\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                            case -1:
                                {
                                    MMessageBox.Show(this, "Поточний рахунок видалений з бази\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                        }
                        if (changeState != 0)
                            break;

                        uiWndBillPrint bPrn = new uiWndBillPrint(this.PD_Order);
                        bPrn.ShowDialog(this);
                        bPrn.Dispose();
                        break;
                    }
                case "SaveBill": // just save and leave opened
                    {
                        if (inventChq)
                            break;

                        int changeState = DataWorkBill.BillWasChanged(AppConfig.Path_Bills, this.PD_Order);
                        switch (changeState)
                        {
                            case 1:
                                {
                                    MMessageBox.Show(this, "Були внесені змінити в поточний рахунок\r\nПерезавантажте рахунок за допомогою меню або натисніть ALT+R", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    break;
                                }
                            case 2:
                                {
                                    MMessageBox.Show(this, "Поточний рахунок вже закритий\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                            case -1:
                                {
                                    MMessageBox.Show(this, "Поточний рахунок видалений з бази\r\nНатисніть ОК для продовження роботи", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    _fl_menuIsActive = false;
                                    this.Menu_ItemClicked(this.billMenu, new ToolStripItemClickedEventArgs(закритиБезЗмінToolStripMenuItem));
                                    break;
                                }
                        }
                        if (changeState != 0)
                            break;

                        BillSave bs = new BillSave(this.PD_Order);
                        if (bs.ShowDialog() == DialogResult.OK)
                        {
                            //if (bs.IsNewBill)
                            this.addBillInfo.Text = string.Format("{0} {1}", "Рахунок №", bs.GetNewBillNo);
                            //this.PD_Order = bs.SavedBill;
                            // else
                            //    this.addBillInfo.Text = "";

                            DataWorkShared.MergeDataTableProperties(ref this.Cheque, bs.SavedBill);

                            this.RefershMenus();

                        }
                        bs.Dispose();
                        break;
                    }
                case "ReloadBill": // ReloadBill
                    {
                        object billName = DataWorkShared.ExtractBillProperty(this.PD_Order, CoreConst.PATH);
                        DataTable LoadedBill = DataWorkBill.LoadCombinedBill(AppConfig.Path_Bills + "\\" + billName.ToString());
                        RowsRemoved_MyEvent(true, true);
                        Cheque.Merge(LoadedBill);
                        this.addBillInfo.Text = string.Format("{0} {1}", "Рахунок №", DataWorkShared.ExtractBillProperty(this.Cheque, mdcore.Common.CoreConst.BILL_NO));
                        UpdateSumInfo(true);
                        break;
                    }
                case "CloseBillWithoutChanges": // CloseBill
                    {
                        RowsRemoved_MyEvent(true, true);
                        break;
                    }
                #endregion
                #region Plugins
                case "SendComPortCommand":
                    {
                        wndAdditional.uiWndAdditionalPortCommands cm = new wndAdditional.uiWndAdditionalPortCommands();
                        cm.ShowDialog();
                        cm.Dispose();
                        //MessageBox.Show(cm.PortCommand);
                        break;
                    }
                #endregion
            }

            _fl_menuIsActive = false;
        }