Exemplo n.º 1
0
        public ActionResult EditConfirmed(BeltAnalysis model)
        {
            if (ModelState.IsValid)
            {
                BeltAnalysis beltAnalysis = _cdb.BeltAnalyzes.Find(model.ID);
                beltAnalysis.IsValid           = false;
                beltAnalysis.LasEditDateTime   = DateTime.Now;
                beltAnalysis.OperatorName      = User.Identity.Name;
                _cdb.Entry(beltAnalysis).State = EntityState.Modified;

                model.LasEditDateTime = DateTime.Now;
                model.IsValid         = true;
                model.OperatorName    = User.Identity.Name;
                model.InheritedFrom   = beltAnalysis.ID;

                List <BeltTransfer> transfers = new List <BeltTransfer>();
                transfers = _cdb.InternalTransfers.Where(x => x.AnalysisID == model.ID).ToList();
                if (transfers != null)
                {
                    foreach (var t in transfers)
                    {
                        t.Analysis          = model;
                        _cdb.Entry(t).State = EntityState.Modified;
                    }
                }

                _cdb.SaveChanges();

                return(RedirectToAction("Index"));
            }

            @ViewBag.Title = "Редактирование анализа для конвейерных весов";
            return(View("Edit", model));
        }
Exemplo n.º 2
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            BeltAnalysis analisys = _cdb.BeltAnalyzes.Find(id);

            if (analisys != null)
            {
                analisys.IsValid         = false;
                analisys.LasEditDateTime = DateTime.Now;
                analisys.OperatorName    = User.Identity.Name;

                _cdb.Entry(analisys).State = EntityState.Modified;
            }

            List <BeltTransfer> transfers = new List <BeltTransfer>();

            transfers = _cdb.InternalTransfers.Where(x => x.AnalysisID == id).ToList();
            if (transfers != null)
            {
                foreach (var t in transfers)
                {
                    t.AnalysisID        = null;
                    _cdb.Entry(t).State = EntityState.Modified;
                }
            }

            _cdb.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        public ActionResult Add(string alltransfers)
        {
            @ViewBag.alltransfers = alltransfers;
            BeltAnalysis model = new BeltAnalysis();

            @ViewBag.Title = "Добавление анализа для конвейерных весов";
            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult Add(BeltAnalysis model, string alltransfers)
        {
            if (ModelState.IsValid)
            {
                //Get the list of transfers to add analysis
                string[]            transfersArray = alltransfers.Split(',');
                List <BeltTransfer> transfers      = new List <BeltTransfer>();

                foreach (var t in transfersArray)
                {
                    if (t != "")
                    {
                        try
                        {
                            transfers.Add(_cdb.InternalTransfers.Where(x => x.ID == t).FirstOrDefault());
                        }
                        catch
                        {
                        }
                    }
                }

                //Bind model
                model.LasEditDateTime = DateTime.Now;
                model.IsValid         = true;
                model.OperatorName    = User.Identity.Name;

                foreach (var t in transfers)
                {
                    if (t.Analysis != null)
                    {
                        BeltAnalysis analisys = new BeltAnalysis();
                        analisys                   = _cdb.BeltAnalyzes.Where(x => x.ID == t.AnalysisID).FirstOrDefault();
                        analisys.IsValid           = false;
                        _cdb.Entry(analisys).State = EntityState.Modified;
                    }

                    t.Analysis          = model;
                    _cdb.Entry(t).State = EntityState.Modified;
                }

                try
                {
                    _cdb.SaveChanges();
                }
                catch
                (Exception)
                { }
                return(RedirectToAction("Index"));
            }

            @ViewBag.alltransfers = alltransfers;
            @ViewBag.Title        = "Добавление анализа для конвейерных весов";
            return(View("Add", model));
        }
Exemplo n.º 5
0
        public ActionResult AnalysisView(string TransferID)
        {
            BeltAnalysis analysis = new BeltAnalysis();

            if (TransferID != "")
            {
                try
                {
                    analysis = _cdb.InternalTransfers.Where(x => x.ID == TransferID).FirstOrDefault().Analysis;
                }
                catch
                {
                }
            }

            ViewBag.TransferID = TransferID;
            @ViewBag.Title     = "Данные проведенного анализа для конвейерных весов";
            return(View(analysis));
        }