Example #1
0
        public void PrecislujOperNum(int p14id_start)
        {
            var rec = Load(p14id_start);
            var rn  = rec.p14OperNum;
            var mq  = new BO.myQuery("p14MasterOper");

            mq.p13id = rec.p13ID;
            BO.p14MasterOper cLast = rec;
            foreach (var c in GetList(mq).OrderBy(p => p.p14RowNum).Where(p => p.p14RowNum > rec.p14RowNum))
            {
                var recP18 = _mother.p18OperCodeBL.Load(c.p18ID);
                if (c.OperCode == cLast.OperCode && recP18.p18IsRepeatable == true)
                {
                    //V následujícím řádku nepřičítává "10" pokud je Kód oper stejný jako předchozí Kód oper (současná funkcionalita), ale navíc (AND) "Opakovaná operace" je TRUE.
                    _db.RunSql("UPDATE p14MasterOper set p14OperNum=@opernum WHERE p14ID=@pid", new { pid = c.pid, opernum = cLast.p14OperNum });
                    c.p14OperNum = cLast.p14OperNum;
                }
                else
                {
                    rn = cLast.p14OperNum + 10;
                    _db.RunSql("UPDATE p14MasterOper set p14OperNum=@opernum WHERE p14ID=@pid", new { pid = c.pid, opernum = rn });
                    c.p14OperNum = rn;
                }
                cLast = c;
            }
        }
Example #2
0
        public int Save(BO.p14MasterOper rec)
        {
            if (rec.p18ID == 0)
            {
                _mother.CurrentUser.AddMessage("Chybí vazba na číselník [Kód operace].");
                return(0);
            }
            var p = new DL.Params4Dapper();

            p.AddInt("pid", rec.p14ID);
            p.AddInt("p13ID", rec.p13ID, true);
            p.AddInt("p19ID", rec.p19ID, true);
            p.AddInt("p18ID", rec.p18ID, true);

            p.AddInt("p14RowNum", -1 + rec.p14RowNum * 100);
            p.AddInt("p14OperNum", rec.p14OperNum);
            p.AddDouble("p14OperParam", rec.p14OperParam);
            p.AddDouble("p14UnitsCount", rec.p14UnitsCount);
            p.AddDouble("p14DurationPreOper", rec.p14DurationPreOper);
            p.AddDouble("p14DurationPostOper", rec.p14DurationPostOper);
            p.AddDouble("p14DurOperUnits", rec.p14DurOperUnits);
            p.AddDouble("p14DurOperMinutes", rec.p14DurOperMinutes);
            if (rec.p14DurOperMinutes > 0 && rec.p14DurOperUnits > 0)
            {
                p.AddDouble("p14DurationOper", rec.p14DurOperMinutes / rec.p14DurOperUnits);
            }
            else
            {
                p.AddDouble("p14DurationOper", rec.p14DurationOper);
            }

            var intPID = _db.SaveRecord("p14MasterOper", p.getDynamicDapperPars(), rec);

            _db.RunSql("UPDATE p14MasterOper SET p14RowNum=p14RowNum*100 WHERE p13ID=@p13id AND p14ID<>@pid", new { p13id = rec.p13ID, pid = intPID });
            _db.RunSql("update a set p14RowNum=RowID from (SELECT ROW_NUMBER() OVER(ORDER BY p14RowNum ASC) AS RowID,* FROM p14MasterOper WHERE p13ID=@p13id) a", new { p13id = rec.p13ID });

            _db.RunSql("UPDATE p13MasterTpv SET p13TotalDuration=(SELECT sum(isnull(p14DurationPreOper,0)+isnull(p14DurationOper,0)+isnull(p14DurationPostOper,0)) FROM p14MasterOper WHERE p13ID=@pid) WHERE p13ID=@pid", new { pid = rec.p13ID });

            return(intPID);
        }