Exemple #1
0
        public IActionResult Record(Models.p14RecordViewModel v)
        {
            if (ModelState.IsValid)
            {
                BO.p14MasterOper c = new BO.p14MasterOper();
                if (v.Rec.pid > 0)
                {
                    c = Factory.p14MasterOperBL.Load(v.Rec.pid);
                }

                c.p13ID         = v.Rec.p13ID;
                c.p19ID         = v.Rec.p19ID;
                c.p18ID         = v.Rec.p18ID;
                c.p14RowNum     = v.Rec.p14RowNum;
                c.p14OperParam  = v.Rec.p14OperParam;
                c.p14OperNum    = v.Rec.p14OperNum;
                c.p14UnitsCount = v.Rec.p14UnitsCount;

                c.p14DurOperMinutes = v.Rec.p14DurOperMinutes;
                c.p14DurOperUnits   = v.Rec.p14DurOperUnits;
                c.p14DurationOper   = v.Rec.p14DurationOper;

                c.p14DurationPreOper  = v.Rec.p14DurationPreOper;
                c.p14DurationPostOper = v.Rec.p14DurationPostOper;

                v.Rec.pid = Factory.p14MasterOperBL.Save(c);
                if (v.Rec.pid > 0)
                {
                    v.SetJavascript_CallOnLoad(v.Rec.pid);
                    return(View(v));
                }
            }

            v.RecP13  = Factory.p13MasterTpvBL.Load(v.Rec.p13ID);
            v.Toolbar = new MyToolbarViewModel(v.Rec);
            v.Toolbar.AllowArchive = false;
            this.Notify_RecNotSaved();
            return(View(v));
        }
Exemple #2
0
        public BO.Result receptura_operace_save(string p13Code, string p18Code, string p19Code, double p14UnitsCount, double p14DurationPreOper, double p14DurationOper, double p14DurationPostOper, int p14OperNum, double p14OperParam, int p14RowNum, double p14DurOperUnits, double p14DurOperMinutes)
        {
            if (string.IsNullOrEmpty(p13Code) == true || string.IsNullOrEmpty(p18Code) == true)
            {
                return(new BO.Result(true, "Na vstupu je povinný kód receptury [p13Code] a kód operace [p18Code]."));
            }
            if (p14RowNum <= 0 || p14OperNum <= 0)
            {
                return(new BO.Result(true, "[p14RowNum] a [p14OperNum] musí být kladné a nenulové číslo."));
            }
            var recP13 = _f.p13MasterTpvBL.LoadByCode(p13Code, 0);

            if (recP13 == null)
            {
                return(new BO.Result(true, string.Format("Nelze načíst recepturu s kódem: {0}.", p13Code)));
            }
            var recP18 = _f.p18OperCodeBL.LoadByCode(p18Code, recP13.p25ID, 0);

            if (recP18 == null)
            {
                return(new BO.Result(true, string.Format("Nelze načíst šablonu operace s kódem: {0}.", p18Code)));
            }
            BO.p19Material recP19 = null;
            if (string.IsNullOrEmpty(p19Code) == false)
            {
                recP19 = _f.p19MaterialBL.LoadByCode(p19Code, 0);
                if (recP19 == null)
                {
                    return(new BO.Result(true, string.Format("Nelze načíst surovinu s kódem: {0}.", p19Code)));
                }
            }

            var mq = new BO.myQuery("p14MasterOper");

            mq.p13id = recP13.pid;
            var lisP14 = _f.p14MasterOperBL.GetList(mq);

            var recP14 = new BO.p14MasterOper()
            {
                p14RowNum = p14RowNum, p13ID = recP13.pid
            };

            if (lisP14.Where(p => p.p14RowNum == p14RowNum).Count() > 0)
            {
                recP14 = lisP14.Where(p => p.p14RowNum == p14RowNum).First();
            }
            recP14.p14OperNum          = p14OperNum;
            recP14.p18ID               = recP18.pid;
            recP14.p14UnitsCount       = p14UnitsCount;
            recP14.p14OperParam        = p14OperParam;
            recP14.p14DurOperUnits     = p14DurOperUnits;
            recP14.p14DurOperMinutes   = p14DurOperMinutes;
            recP14.p14DurationOper     = p14DurationOper;
            recP14.p14DurationPreOper  = p14DurationPreOper;
            recP14.p14DurationPostOper = p14DurationPostOper;

            if (recP19 != null)
            {
                recP14.p19ID = recP19.pid;
            }

            int intP14ID = _f.p14MasterOperBL.Save(recP14);

            if (intP14ID > 0)
            {
                return(new BO.Result(false, "Uloženo"));
            }
            else
            {
                string strErrs = string.Join(" ** ", _f.CurrentUser.Messages4Notify.Select(p => p.Value));
                return(new BO.Result(true, strErrs));
            }
        }