コード例 #1
0
        private void PivotGridControl2CellClickInputData(object sender, CellInputDataEventArgs e)
        {
            if (e.Type == InputDataTypes.Supplier)
            {
                _args = e;
                var windowSupplier = new WindowSupplier(_db);
                windowSupplier.SupplierSelected += WindowSupplierSupplierSelected;
                ((UIElement)Content).IsEnabled = false;
                Cursor = Cursors.Wait;
                windowSupplier.ShowDialog();
                ((UIElement)Content).IsEnabled = true;
                Cursor = Cursors.Arrow;
            }
            else
            {
                var setIL = _db.DataTableGetILByCondition(Table.TableRowSource, e.ConditionValues,
                                                             e.Filters);
                if (e.Type == InputDataTypes.SourceWh)
                {
                    var chainGroup = _db.DataTableGetChainForCondition(setIL, Convert.ToInt32(e.SetValues[0].Value));
                    if (chainGroup != null)
                    {
                        var windowChain = new WindowChain(_db, chainGroup, setIL,_db.DataTableGetSourceMethodByIL(setIL)==SourceMethods.T);
                        windowChain.Apply += WindowChainApply;
                        windowChain.ShowDialog();

                        //var windowChainNative = new WindowChainNative(_db, chainGroup);
                        //windowChainNative.ShowDialog();
                    }
                    return;
                }

                var lockedIL = new SortedSet<IL>();
                if (_db.DataTableRowSourceUpdateCustom(e.SetValues, setIL, ref lockedIL) == false)
                {
                    MessageBox.Show("Ошибка при обновлении источника: " + _db.Error, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    if (lockedIL.Count > 0)
                        MessageBox.Show("Не удалось выполненить действие для следующих товаров-подразделений: " + string.Join(",", lockedIL));
                    /*
                    if (e.Type == InputDataTypes.SourceMethod && e.SetValues[0].Value.Equals("S"))
                    {
                        //_db.FillDataTableCustom(DbManagerDynamic.TableSecSource);
                        //_db.DataTableSecSourceUpdateCustomWithoutDb(e.SetValues, e.ConditionValues);
                        _db.LogisticChainClear();
                    }
                     */
                    _pivotGridControl2.ReloadData();
                }
            }
            return;
        }
コード例 #2
0
        private void GridControl1MouseClick(object sender, MouseButtonEventArgs e)
        {
            if (gridControl1.View.GetRowHandleByMouseEventArgs(e) < -100) return;
            if (gridControl1.GetFocusedRow() == null) return;

            int id = Convert.ToInt32(gridControl1.GetFocusedRowCellValue("Id"));
            var chain = Chain.GetChainById(_chainGroup, id);
            if (chain == null) return;

            #region EXPENDMATERIAL

            var userWhList = _db.UserWhList.Keys.ToList();
/*
            var whs = _db.DataTableGetWhRowsByItem(chain.Item);

            foreach (var wh in whs)
            {
                if (userWhList.Contains(wh)) userWhList.Remove(wh);
            }
*/
            #endregion

            //if (gridControl1.View.FocusedColumn.FieldName.Equals("SourceMethodNew"))
            if (gridControl1.Columns["SourceMethodNew"].IsFocused)
            {
                //int id = Convert.ToInt32(gridControl1.GetFocusedRowCellValue("Id"));
                //var chain = Chain.GetChainById(_chainGroup, id);
                //if (chain == null) return;

                var menuItemMethodNew1 = new MenuItem { Header = SourceMethods.S.Description(), Tag = SourceMethods.S };
                menuItemMethodNew1.Click += ContextMenuItemMethodNewClick;

                var menu = new ContextMenu();
                menu.Items.Add(menuItemMethodNew1);

                foreach (var wh in userWhList)
                //foreach (var wh in _db.UserWhList)
                {
                    if (chain.WhExists(wh) == false) //wh.Key
                    {
                        var menuItemMethodNew2 = new MenuItem
                                                     {
                                                         Header = SourceMethods.W.Description(),
                                                         Tag = SourceMethods.W
                                                     };
                        menuItemMethodNew2.Click += ContextMenuItemMethodNewClick;

                        var menuItemMethodNew3 = new MenuItem
                                                     {
                                                         Header = SourceMethods.T.Description(),
                                                         Tag = SourceMethods.T
                                                     };
                        menuItemMethodNew3.Click += ContextMenuItemMethodNewClick;
                        menu.Items.Add(menuItemMethodNew2);
                        menu.Items.Add(menuItemMethodNew3);
                        break;
                    }
                }

                menu.IsOpen = true;
            }
            else if (gridControl1.Columns["SourceWhNew"].IsFocused)
            {
                var value = (ChainValue)gridControl1.GetFocusedRowCellValue("SourceMethodNew");
                if (value.State != ValueStates.Valid) return;
                if (Convert.ToChar(value.Value) == (char)SourceMethods.S) return;

                var menu = new ContextMenu();

                //int id = Convert.ToInt32(gridControl1.GetFocusedRowCellValue("Id"));
                //var chain = Chain.GetChainById(_chainGroup, id);
                //if (chain == null) return;

                bool visible = false;
                foreach (var wh in userWhList)
                //foreach (var wh in _db.UserWhList)
                {
                    if (chain.WhExists(wh)) continue;
                    if (chain.Loc == wh) continue;
                    var menuItemWhNew = new MenuItem { Header = wh };
                    menuItemWhNew.Click += ContextMenuItemWhNewClick;
                    menu.Items.Add(menuItemWhNew);
                    visible = true;
                }
                //if (!chain.WhExists(44))
                //{
                //    var menuItemWhNew1 = new MenuItem { Header = "44" };
                //    menuItemWhNew1.Click += ContextMenuItemWhNew1Click;
                //    menu.Items.Add(menuItemWhNew1);
                //    visible = true;
                //}

                //if (!chain.WhExists(121))
                //{
                //    var menuItemWhNew2 = new MenuItem { Header = "121" };
                //    menuItemWhNew2.Click += ContextMenuItemWhNew2Click;
                //    menu.Items.Add(menuItemWhNew2);
                //    visible = true;
                //}

                //if (!chain.WhExists(174))
                //{
                //    var menuItemWhNew3 = new MenuItem { Header = "174" };
                //    menuItemWhNew3.Click += ContextMenuItemWhNew3Click;
                //    menu.Items.Add(menuItemWhNew3);
                //    visible = true;
                //}

                if (visible) menu.IsOpen = true;
            }
            else if (gridControl1.Columns["SupplierNew"].IsFocused || gridControl1.Columns["SupplierDescNew"].IsFocused)
            {
                #region Check Action State

                //int id = Convert.ToInt32(gridControl1.GetFocusedRowCellValue("Id"));
                int seq = Convert.ToInt32(gridControl1.GetFocusedRowCellValue("Seq"));

                //var chain = Chain.GetChainById(_chainGroup, id);
                //if (chain == null) return;

                #endregion

                //if ((Actions)chain.Nodes[seq - 1].Action.Value == Actions.Leave || (Actions)chain.Nodes[seq - 1].Action.Value == Actions.Transit)
                //{
                if (chain.Nodes.Count == seq)
                {
                    var windowSupplier = new WindowSupplier(_db);
                    windowSupplier.SupplierSelected += WindowSupplierSupplierSelected;
                    windowSupplier.ShowDialog();
                }
                if (chain.Nodes.Count > seq)
                {
                    if ((Actions)chain.Nodes[seq].Action.Value == Actions.Switch)
                    {
                        var windowSupplier = new WindowSupplier(_db);
                        windowSupplier.SupplierSelected += WindowSupplierSupplierSelected;
                        windowSupplier.ShowDialog();
                    }
                }
                //}
            }
            else if (gridControl1.Columns["Action"].IsFocused)
            {
                #region Check Action State

                //int id = Convert.ToInt32(gridControl1.GetFocusedRowCellValue("Id"));
                int seq = Convert.ToInt32(gridControl1.GetFocusedRowCellValue("Seq"));

                //var chain = Chain.GetChainById(_chainGroup, id);
                //if (chain == null) return;

                //if ((Actions)chain.Nodes[seq - 1].Action.Value == Actions.Transit) return;

                #endregion

                var menu = new ContextMenu();

                if (chain.Nodes.Count == seq || (chain.Nodes.Count > seq ? (Actions)chain.Nodes[seq].Action.Value : Actions.Leave) == Actions.Switch)
                {
                    var menuItemActionNew1 = new MenuItem { Header = Actions.Leave.Description(), Tag = Actions.Leave };
                    menuItemActionNew1.Click += ContextMenuItemActionNewClick;
                    menu.Items.Add(menuItemActionNew1);

                    var menuItemActionNew2 = new MenuItem { Header = Actions.Switch.Description(), Tag = Actions.Switch };
                    menuItemActionNew2.Click += ContextMenuItemActionNewClick;
                    menu.Items.Add(menuItemActionNew2);
                }

                if (chain.Nodes.Count == seq && !_isSourceTransit)
                {
                    var menuItemActionNew3 = new MenuItem { Header = Actions.Close.Description(), Tag = Actions.Close };
                    menuItemActionNew3.Click += ContextMenuItemActionNewClick;
                    menu.Items.Add(menuItemActionNew3);
                }

                // transit feature
                var menuItemActionNew4 = new MenuItem { Header = Actions.Transit.Description(), Tag = Actions.Transit };
                menuItemActionNew4.Click += ContextMenuItemActionNewClick;
                menu.Items.Add(menuItemActionNew4);

                if (menu.Items.Count > 0) menu.IsOpen = true;
            }
        }
コード例 #3
0
 private void SupplierNewSelectClick(object sender, RoutedEventArgs e)
 {
     var windowSupplier = new WindowSupplier(_db);
     windowSupplier.SupplierSelected += WindowSupplierSupplierSelected;
     windowSupplier.ShowDialog();
 }