Ejemplo n.º 1
0
        // Добавление новой группы в "дерево данных"
        private void AddNewGroup()
        {
            // попытаемся получить вышестоящий узел в дереве
            // ReSharper disable once SuggestVarOrType_SimpleTypes
            TreeNode pNode = treeDataConstructor.SelectedNode ?? treeDataConstructor.Nodes[0];


            if (pNode == null) // всетаки неудалось.......
            {
                MessageBox.Show(@"DANGER!!! Ошибка указания родителя?!?!");
                return;
            }

            // найдем вышестоящий узел в ListPrimitives
            PrimitivNode pnfind = FindNodeWithGuid(pNode.Name);

            if (pnfind == null)
            {
                MessageBox.Show(@"DANGER!!! Ошибка поиска родителя?!?!");
                return;
            }

            // Сразу проверим узел выше, т.к. каталог можно создавать в корне дерева, или внутри другого каталога, а создание каталога внутри других элементов нелогично
            if (!(pnfind.TypeNode == PrimitivType.Catalog || pnfind.TypeNode == PrimitivType.Cycler || pnfind.TypeNode == PrimitivType.Rotate))
            {
                MessageBox.Show(@"Создание каталога в нутри данного примитива невозможно!");
                return;
            }

            // вызовем диалог добавления группы
            frmCatalog fCatalog = new frmCatalog(_mf)
            {
                deltaX = { Value = (decimal)_lastX },
                deltaY = { Value = (decimal)_lastY },
                deltaZ = { Value = (decimal)_lastZ }
            };

            DialogResult dlResult = fCatalog.ShowDialog();

            if (dlResult == DialogResult.OK)
            {
                _lastX = (double)fCatalog.deltaX.Value;
                _lastY = (double)fCatalog.deltaY.Value;
                _lastZ = (double)fCatalog.deltaZ.Value;

                PrimitivNode pn = new PrimitivNode(new PrimitivCatalog((double)fCatalog.deltaX.Value, (double)fCatalog.deltaY.Value, (double)fCatalog.deltaZ.Value, (double)fCatalog.deltaRotate.Value, fCatalog.textBoxName.Text));
                pnfind.Nodes.Add(pn);
                RefreshTree();
            }
        }
Ejemplo n.º 2
0
        // ReSharper disable once FunctionComplexityOverflow
        private void OpenFormDialog()
        {
            if (treeDataConstructor.SelectedNode == null)
            {
                return;
            }

            // Необходимость перезаполнения дерева обновленными данными
            bool needRefreshTree = false;

            //получим примитив по гуиду
            // ReSharper disable once SuggestVarOrType_SimpleTypes
            PrimitivNode pfind = FindNodeWithGuid(treeDataConstructor.SelectedNode.Name);

            //определим его тип, и откроем необходимый диалог

            if (pfind.TypeNode == PrimitivType.Catalog)
            {
                // вызовем диалог добавления группы
                // ReSharper disable once SuggestVarOrType_SimpleTypes
                frmCatalog fCatalog = new frmCatalog(_mf)
                {
                    deltaX      = { Value = (decimal)pfind.Catalog.DeltaX },
                    deltaY      = { Value = (decimal)pfind.Catalog.DeltaY },
                    deltaZ      = { Value = (decimal)pfind.Catalog.DeltaZ },
                    textBoxName = { Text = pfind.Catalog.Name },
                    deltaRotate = { Value = (decimal)pfind.Catalog.DeltaRotate }
                };

                // ReSharper disable once SuggestVarOrType_SimpleTypes
                DialogResult dlResult = fCatalog.ShowDialog();

                if (dlResult == DialogResult.OK)
                {
                    pfind.Catalog.DeltaX      = (double)fCatalog.deltaX.Value;
                    pfind.Catalog.DeltaY      = (double)fCatalog.deltaY.Value;
                    pfind.Catalog.DeltaZ      = (double)fCatalog.deltaZ.Value;
                    pfind.Catalog.Name        = fCatalog.textBoxName.Text;
                    pfind.Catalog.DeltaRotate = (double)fCatalog.deltaRotate.Value;

                    needRefreshTree = true;
                }
            }

            if (pfind.TypeNode == PrimitivType.Cycler)
            {
                // вызовем диалог добавления группы
                // ReSharper disable once SuggestVarOrType_SimpleTypes
                frmCycler fCycler = new frmCycler(_mf)
                {
                    numStart    = { Value = (decimal)pfind.Cycler.CStart },
                    numStop     = { Value = (decimal)pfind.Cycler.CStop },
                    numStep     = { Value = (decimal)pfind.Cycler.CStep },
                    textBoxName = { Text = pfind.Cycler.Name },
                    cbX         = { Checked = pfind.Cycler.AllowDeltaX },
                    cbY         = { Checked = pfind.Cycler.AllowDeltaY },
                    cbZ         = { Checked = pfind.Cycler.AllowDeltaZ }
                };


                // ReSharper disable once SuggestVarOrType_SimpleTypes
                DialogResult dlResult = fCycler.ShowDialog();

                if (dlResult == DialogResult.OK)
                {
                    pfind.Cycler.CStart = (double)fCycler.numStart.Value;
                    pfind.Cycler.CStop  = (double)fCycler.numStop.Value;
                    pfind.Cycler.CStep  = (double)fCycler.numStep.Value;

                    pfind.Cycler.Name        = fCycler.textBoxName.Text;
                    pfind.Cycler.AllowDeltaX = fCycler.cbX.Checked;
                    pfind.Cycler.AllowDeltaY = fCycler.cbY.Checked;
                    pfind.Cycler.AllowDeltaZ = fCycler.cbZ.Checked;

                    needRefreshTree = true;
                }
            }


            if (pfind.TypeNode == PrimitivType.Rotate)
            {
                // вызовем диалог добавления группы
                // ReSharper disable once SuggestVarOrType_SimpleTypes
                frmRotate frotate = new frmRotate(_mf)
                {
                    centerX          = { Value = (decimal)pfind.Rotate.X },
                    centerY          = { Value = (decimal)pfind.Rotate.Y },
                    centerZ          = { Value = (decimal)pfind.Rotate.Z },
                    rotateRadius     = { Value = (decimal)pfind.Rotate.Radius },
                    rotateStartAngle = { Value = (decimal)pfind.Rotate.AngleStart },
                    rotateStopAngle  = { Value = (decimal)pfind.Rotate.AngleStop },
                    rotateStepAngle  = { Value = (decimal)pfind.Rotate.AngleStep },
                    deltaStepRadius  = { Value = (decimal)pfind.Rotate.DeltaStepRadius },
                    RotateRotates    = { Value = (decimal)pfind.Rotate.RotateRotates },
                    textBoxName      = { Text = pfind.Rotate.Name }
                };



                DialogResult dlResult = frotate.ShowDialog();

                if (dlResult == DialogResult.OK)
                {
                    pfind.Rotate.Name = frotate.textBoxName.Text;

                    pfind.Rotate.X = (double)frotate.centerX.Value;
                    pfind.Rotate.Y = (double)frotate.centerY.Value;
                    pfind.Rotate.Z = (double)frotate.centerZ.Value;

                    pfind.Rotate.Radius     = (double)frotate.rotateRadius.Value;
                    pfind.Rotate.AngleStart = (double)frotate.rotateStartAngle.Value;
                    pfind.Rotate.AngleStop  = (double)frotate.rotateStopAngle.Value;
                    pfind.Rotate.AngleStep  = (double)frotate.rotateStepAngle.Value;

                    pfind.Rotate.DeltaStepRadius = (double)frotate.deltaStepRadius.Value;
                    pfind.Rotate.RotateRotates   = (double)frotate.RotateRotates.Value;

                    needRefreshTree = true;
                }
            }



            if (pfind.TypeNode == PrimitivType.Point)
            {
                // вызовем диалог добавления группы
                frmPoint fPoint = new frmPoint
                {
                    numPosX = { Value = (decimal)pfind.Point.X },
                    numPosY = { Value = (decimal)pfind.Point.Y },
                    numPosZ = { Value = (decimal)pfind.Point.Z }
                };

                DialogResult dlResult = fPoint.ShowDialog();

                if (dlResult == DialogResult.OK)
                {
                    pfind.Point.X   = (double)fPoint.numPosX.Value;
                    pfind.Point.Y   = (double)fPoint.numPosY.Value;
                    pfind.Point.Z   = (double)fPoint.numPosZ.Value;
                    needRefreshTree = true;
                }
            }

            if (needRefreshTree)
            {
                RefreshTree();
            }
        }
Ejemplo n.º 3
0
        static public void ShowMatList(BaseEntities db, WaybillList wb)
        {
            var f = new frmCatalog(2);

            f.uc.xtraTabPage3.PageVisible  = false;
            f.uc.xtraTabPage4.PageVisible  = false;
            f.uc.xtraTabPage5.PageVisible  = false;
            f.uc.xtraTabPage12.PageVisible = false;
            f.uc.xtraTabPage13.PageVisible = false;
            f.uc.xtraTabPage14.PageVisible = true;
            f.uc.wb        = wb;
            f.uc.isMatList = true;

            if (f.ShowDialog() == DialogResult.OK)
            {
                foreach (var item in f.uc.custom_mat_list.OrderBy(o => o.Num).ToList())
                {
                    var price = (item.Price ?? 0);

                    var wbd = db.WaybillDet.Add(new WaybillDet
                    {
                        WbillId      = wb.WbillId,
                        Num          = wb.WaybillDet.Count(),
                        MatId        = item.MatId,
                        WId          = item.WId,
                        Amount       = item.Amount,
                        Price        = price,
                        Discount     = 0,
                        Nds          = wb.Nds,
                        CurrId       = wb.CurrId,
                        OnDate       = wb.OnDate,
                        OnValue      = wb.OnValue,
                        BasePrice    = price + Math.Round(price * wb.Nds.Value / 100, 2),
                        PosKind      = 0,
                        PosParent    = 0,
                        DiscountKind = 0
                    });

                    if (wb.WType == -16)
                    {
                        var dis = db.GetDiscount(wb.KaId, item.MatId).FirstOrDefault() ?? 0.00m;
                        wbd.Discount  = dis;
                        wbd.Price     = item.Price - Math.Round((item.Price.Value * dis / 100), 2);
                        wbd.BasePrice = item.Price + Math.Round(item.Price.Value * wb.Nds.Value / 100, 2);
                    }
                    db.SaveChanges();

                    if (wb.WType == 16)
                    {
                        db.WMatTurn.Add(new WMatTurn()
                        {
                            SourceId = wbd.PosId,
                            PosId    = wbd.PosId,
                            WId      = wbd.WId.Value,
                            MatId    = wbd.MatId,
                            OnDate   = wbd.OnDate.Value,
                            TurnType = 3,
                            Amount   = wbd.Amount
                        });
                    }
                }
                db.Save(wb.WbillId);
            }
        }
Ejemplo n.º 4
0
        static public object ShowDirectList(object old_id, int Typ)
        {
            switch (Typ)
            {
            case 1:
                using (var f = new frmCatalog(1))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Контрагенти";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.KaGridView.GetFocusedRow() as dynamic).KaId;
                    }
                }

                break;

            case 2:
                using (var f = new frmCatalog(null, 25))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Склади";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.WarehouseGridView.GetFocusedRow() as Warehouse).WId;
                    }
                }
                break;


            case 3:
                using (var f = new frmCatalog(null, 5))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Службовці";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.KaGridView.GetFocusedRow() as dynamic).KaId;
                    }
                }
                break;

            case 4:
                using (var f = new frmCatalog(null, 64))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Каси";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.CashDesksGridView.GetFocusedRow() as CashDesks).CashId;
                    }
                }
                break;

            case 5:      //Товари
                using (var f = new frmCatalog(2))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Товари";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.MatGridView.GetFocusedRow() as GetMatList_Result).MatId;
                    }
                }
                break;

            case 6:
                using (var f = new frmCatalog(null, 102))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Статті витрат";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.ChargeTypeGridView.GetFocusedRow() as ChargeType).CTypeId;
                    }
                }
                break;

            case 7:

                using (var f = new frmCatalog(null, 43))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Країни";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.CountriesGridView.GetFocusedRow() as Countries).CId;
                    }
                }
                break;

            case 8:
                using (var f = new frmCatalog(null, 40))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Категорії цін";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.PriceTypesGridView.GetFocusedRow() as dynamic).PTypeId;
                    }
                }

                break;

            case 9:
                using (var f = new frmCatalog(null, 11))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Банки";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.BanksGridView.GetFocusedRow() as Banks).BankId;
                    }
                }
                break;

            case 10:
                using (var f = new frmCatalog(null, 12))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Типи рахунків в банку";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.AccountTypeGridView.GetFocusedRow() as AccountType).TypeId;
                    }
                }
                break;

            case 11:
                using (var f = new frmCatalog(3))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Послуги";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.ServicesGridView.GetFocusedRow() as v_Services).SvcId;
                    }
                }
                break;

            case 12:
                using (var f = new frmCatalog(null, 2))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Одиниці виміру";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.MeasuresGridView.GetFocusedRow() as Measures).MId;
                    }
                }
                break;

            case 13:
                using (var f = new frmCatalog(null, 53))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Рецепти";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.MatRecipeGridView.GetFocusedRow() as dynamic).RecId;
                    }
                }
                break;

            case 14:
                using (var f = new frmCatalog(null, 112))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Техпроцеси";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        var tp = f.uc.TechProcessGridView.GetFocusedRow() as TechProcess;
                        if (tp != null)
                        {
                            old_id = tp.ProcId;
                        }
                    }
                }
                break;

            case 15:
                using (var f = new frmCatalog(null, 42))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Обвалка";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.MatRecipeGridView.GetFocusedRow() as dynamic).RecId;
                    }
                }
                break;

            case 16:
                using (var f = new frmCatalog(null, 123))
                {
                    f.uc.isDirectList = true;
                    f.Text            = "Підготовка сировини";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        old_id = (f.uc.MatRecipeGridView.GetFocusedRow() as dynamic).RecId;
                    }
                }
                break;
            }

            return(old_id);
        }
Ejemplo n.º 5
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            frmCatalog frm = new frmCatalog();

            frm.Show();
        }
Ejemplo n.º 6
0
        private void manageCatalogToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmCatalog frm = new frmCatalog();

            frm.Show();
        }