コード例 #1
0
        public string GetData()
        {
            int DC = MvcApplication.CurrentDC();

            var request =
                (from s in db.ShipmentControl
                 where s.Planned_ship_date < DateTime.Now &&
                 s.DC == DC

                 select new ShipControlView()
            {
                ID = s.ID,
                DC = s.DC,
                Internal_shipment_num = s.Internal_shipment_num,
                Shipment_id = s.Shipment_id,
                Route_num = s.Route_num,
                Planned_ship_date = s.Planned_ship_date
            });

            List <ShipControlView> ViewModels = request.ToList();



            return(JsonConvert.SerializeObject(ViewModels));
        }
コード例 #2
0
        public ActionResult SetApparat(int Id, string typeA)
        {
            int DC = MvcApplication.CurrentDC();

            //var request =
            //        (from s in db.Application
            //         join pers in db.Person on s.BarcodePerson equals pers.BarcodePerson
            //         join equip in db.Equipment on s.BarcodeEquipment equals equip.BarcodeEquipment
            //         where (s.BarcodeEquipment==Id & s.SetUser == null)
            //         select new ApplicationViewModel
            //         {
            //             BarcodePerson = s.BarcodePerson,
            //             NamePerson = pers.NamePerson,
            //             BarcodeEquipment = s.BarcodeEquipment,
            //             NameEquipment = equip.NameEquipment,
            //             SerialNumber = equip.SerialNumberEquipment,
            //             GetTime = s.GetTime,
            //             SetTime = s.SetTime,
            //             GetUser = s.GetUser,
            //             SetUser = s.SetUser,
            //             Commment = s.Comment
            //         });

            App_ApplicationModels apparat = db.Application
                                            .Where(a => a.BarcodeEquipment == Id && a.SetTime == new DateTime(2017, 1, 1) && a.TypeEquipment == typeA && a.DC == DC).First();

            return(View(apparat));
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "BarcodeEquipment,NameEquipment,SerialNumberEquipment")] App_EquipmentModels equipment)
        {
            int DC = MvcApplication.CurrentDC();

            if (!CheckExistingEquipment(equipment.BarcodeEquipment))
            {
                ModelState.AddModelError("BarcodeEquipment", "Этот оборудование уже добавлено");
                return(View(equipment));
            }

            try
            {
                if (ModelState.IsValid)
                {
                    equipment.DC = DC;

                    db.Equipment.Add(equipment);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.)
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }

            return(View(equipment));
        }
コード例 #4
0
        public ActionResult Edit(int id, int UserProperty1, int UserProperty2)
        {
            int DC = MvcApplication.CurrentDC();

            App_PersonModels personEdit = db.Person.Find(id);

            try
            {
                if (ModelState.IsValid)
                {
                    personEdit.UserProperty1 = UserProperty1;

                    personEdit.UserProperty2 = UserProperty2;

                    //applicationSet.BarcodePersonSet = BarcodePersonSet;



                    db.Entry(personEdit).State = EntityState.Modified;

                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.)
                ModelState.AddModelError("ModelError", "Невозможно сохранить. Попробуйте снова, если проблема повторится, напишите на Problems.");
            }

            return(RedirectToAction("Index"));
        }
コード例 #5
0
        public ActionResult Edit(int Id)
        {
            int DC = MvcApplication.CurrentDC();

            App_PersonModels person = db.Person.Find(Id);

            return(View(person));
        }
コード例 #6
0
        public ActionResult ViewArchive(string SearchString)
        {
            int res = 0;

            int DC = MvcApplication.CurrentDC();

            var request =
                (from a in db.Application
                 join p in db.Person on new
            {
                j1 = a.BarcodePersonGet,
                j2 = a.DC
            }  equals
                 new { j1 = p.BarcodePerson,
                       j2 = p.DC }

                 join ps in db.Person on new
            {
                j11 = a.BarcodePersonSet,
                j22 = a.DC
            } equals
                 new
            {
                j11 = ps.BarcodePerson,
                j22 = ps.DC
            }

                 where a.SetTime != new DateTime(2017, 1, 1) && a.DC == DC
                 orderby a.GetTime
                 select new ApplicationView
            {
                unicumvalue = a.Id,
                BarcodePersonGet = a.BarcodePersonGet,
                NamePersonGet = p.NamePerson,
                BarcodeEquipment = a.BarcodeEquipment,
                NameEquipment = a.TypeEquipment,
                GetTime = a.GetTime,
                BarcodePersonSet = a.BarcodePersonSet,
                NamePersonSet = ps.NamePerson,
                SetTime = a.SetTime,
                Comment = a.Comment,
                DC = a.DC
            });

            if ((!String.IsNullOrEmpty(SearchString)) && (int.TryParse(SearchString, out res)))

            {
                request = request.Where(b => b.BarcodeEquipment == res);
            }


            List <ApplicationView> ViewModel = request.ToList();


            return(View(ViewModel));
        }
コード例 #7
0
        public ActionResult Create([Bind(Include = "BarcodePerson,NamePerson")] App_PersonModels person)
        {
            int DC = MvcApplication.CurrentDC();

            try
            {
                int rezult;

                string number = Convert.ToString(person.BarcodePerson, 16);

                try
                {
                    rezult = Convert.ToInt32(number.Substring(number.Length - 4), 16);
                    person.BarcodePerson = rezult;
                }

                catch
                {
                    ModelState.AddModelError("BarcodePerson", "Ошибка сканирования");
                    return(View(person));
                }
            }
            catch
            {
                ModelState.AddModelError("BarcodePerson", "Ошибка считывания");
                return(View(person));
            }

            if (!CheckExistingPerson(person.BarcodePerson))
            {
                ModelState.AddModelError("BarcodePerson", "Этот сотрудник уже заведен");
                return(View(person));
            }

            try
            {
                if (ModelState.IsValid)
                {
                    //PersonModels p = new PersonModels();
                    //p.BarcodePerson = person.BarcodePerson;
                    //p.NamePerson = person.NamePerson;
                    person.DC = DC;
                    db.Person.Add(person);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.)
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }

            return(View(person));
        }
コード例 #8
0
        public ActionResult Index()
        {
            int DC = MvcApplication.CurrentDC();

            //var personView = new PersonView();
            _personView.PersonMds = db.Person
                                    .Where(n => n.DC == DC)
                                    .OrderBy(n => n.NamePerson);

            return(View(_personView));
        }
コード例 #9
0
        public ActionResult Index()
        {
            int DC            = MvcApplication.CurrentDC();
            var equipmentView = new EquipmentView();

            equipmentView.EquipmentMds = db.Equipment
                                         .Where(n => n.DC == DC)
                                         .OrderBy(n => n.NameEquipment);

            return(View(equipmentView));
        }
コード例 #10
0
        public bool ExistingApp(int BarcodeEquipment, string TypeEquipment)
        {
            int DC = MvcApplication.CurrentDC();

            if (BarcodeEquipment > 0)
            {
                return(db.Application.Any(a => a.BarcodeEquipment == BarcodeEquipment && a.SetTime == new DateTime(2017, 1, 1) && a.TypeEquipment == TypeEquipment && a.DC == DC));
            }
            else
            {
                return(false);
            }
        }
コード例 #11
0
        public bool ExistingPerson(int BarcodePersonGet)
        {
            int DC = MvcApplication.CurrentDC();

            if (BarcodePersonGet > 0)
            {
                return(db.Person.Any(a => a.BarcodePerson == BarcodePersonGet && a.DC == DC));
            }
            else
            {
                return(false);
            }
        }
コード例 #12
0
        public bool ExistingEquipment(int BarcodeEquipment, string TypeEquipment)
        {
            int DC = MvcApplication.CurrentDC();

            if (BarcodeEquipment > 0)
            {
                return(db.Equipment.Any(a => a.BarcodeEquipment == BarcodeEquipment && a.NameEquipment == TypeEquipment && a.DC == DC));
            }
            else
            {
                return(false);
            }
        }
コード例 #13
0
        public bool CheckExistingEquipment(int BarcodeEquipment)
        {
            int DC = MvcApplication.CurrentDC();

            if (BarcodeEquipment > 0)
            {
                return(!db.Equipment.Any(a => a.BarcodeEquipment == BarcodeEquipment && a.DC == DC));
            }
            else
            {
                return(false);
            }
        }
コード例 #14
0
        public string ShupmentDetail(int Id)
        {
            int DC = MvcApplication.CurrentDC();

            var request =
                (from s in db.ShipmentControl
                 where s.Planned_ship_date < DateTime.Now &&
                 s.DC == DC && s.ID == Id

                 select new ShipDetail()
            {
                Tovaroved = s.Tovaroved,
                Type_product = s.Type_product
            });

            List <ShipDetail> ViewModels1 = request.ToList();



            return(JsonConvert.SerializeObject(ViewModels1));
        }
コード例 #15
0
        //public ActionResult ViewEquipment(int? Id, string typeT)
        public ActionResult ViewEquipment(App_EquipmentModels equipmentJS)
        {
            int DC = MvcApplication.CurrentDC();

            App_EquipmentModels equipment = new App_EquipmentModels();
            {
                if (equipmentJS != null & db.Equipment.Any(a => a.BarcodeEquipment == equipmentJS.BarcodeEquipment && a.NameEquipment == equipmentJS.NameEquipment && a.DC == DC))
                {
                    equipment = db.Equipment.First(a => a.BarcodeEquipment == equipmentJS.BarcodeEquipment && a.NameEquipment == equipmentJS.NameEquipment && a.DC == DC);
                }

                else
                {
                    equipment.NameEquipment         = "";
                    equipment.SerialNumberEquipment = "";
                }

                ViewBag.NameEquipment = equipment.NameEquipment;
                ViewBag.SerialNumber  = equipment.SerialNumberEquipment;
                ViewBag.Condition     = equipment.Condition;

                return(PartialView());
            }
        }
コード例 #16
0
        public ActionResult ViewPerson(App_PersonModels personJS)

        {
            int DC = MvcApplication.CurrentDC();

            App_PersonModels person = new App_PersonModels();

            personJS.BarcodePerson = convertTo(personJS.BarcodePerson);

            if (personJS != null & personJS.BarcodePerson > 0)
            {
                person = db.Person.First(p => p.BarcodePerson == personJS.BarcodePerson && p.DC == DC);
            }


            else
            {
                person.NamePerson = "";
            }



            ViewBag.Person = person.NamePerson;

            int TypicalEquipment;

            switch (personJS.NamePerson)
            {
            case "РЧ терминал":
                TypicalEquipment = person.UserProperty1;
                break;

            case "Радиостанция":
                TypicalEquipment = person.UserProperty2;
                break;

            default:
                TypicalEquipment = 0;
                break;
            }

            if (TypicalEquipment > 0)
            {
                App_EquipmentModels equipment = new App_EquipmentModels();

                equipment = db.Equipment.First(e => e.BarcodeEquipment == TypicalEquipment && e.DC == DC && e.NameEquipment == personJS.NamePerson);

                ViewBag.SerialNumber = equipment.SerialNumberEquipment;

                ViewBag.Condition = equipment.Condition;
            }

            else
            {
                ViewBag.SerialNumber = "";

                ViewBag.Condition = "";
            }

            ViewBag.TypicalEquipmentId = TypicalEquipment;


            return(PartialView());
        }
コード例 #17
0
        public ActionResult SetApparat(int id, int BarcodePersonSet, string Comment, string TypeEquipment, bool cbNew)


        {
            int DC = MvcApplication.CurrentDC();



            App_ApplicationModels applicationSet = db.Application
                                                   .Where(a => a.BarcodeEquipment == id && a.SetTime == new DateTime(2017, 1, 1) && a.TypeEquipment == TypeEquipment && a.DC == DC).First();

            //Конвертация
            if (convertTo(BarcodePersonSet) > 1)
            {
                applicationSet.BarcodePersonSet = convertTo(BarcodePersonSet);
            }
            else
            {
                ModelState.AddModelError("BarcodePersonSet", "Ошибка сканирования");
                return(View(applicationSet));
            }

            if (!ExistingPerson(applicationSet.BarcodePersonSet))
            {
                ModelState.AddModelError("BarcodePersonSet", "Этого сотрудника нет в списке");
                return(View(applicationSet));
            }

            if (!cbNew)
            {
                ModelState.AddModelError("BarcodeEquipment", "Проверьте, что оборудование рабочее");
                return(View(applicationSet));
            }



            try
            {
                if (ModelState.IsValid)
                {
                    applicationSet.SetTime = DateTime.Now;

                    //applicationSet.BarcodePersonSet = BarcodePersonSet;

                    applicationSet.UserSet = User.Identity.Name.ToString().Replace("HCLASS\\", "");

                    applicationSet.Comment = Comment;


                    db.Entry(applicationSet).State = EntityState.Modified;

                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.)
                ModelState.AddModelError("ModelError", "Невозможно сохранить. Попробуйте снова, если проблема повторится, напишите на Problems.");
            }

            return(RedirectToAction("Index"));
        }
コード例 #18
0
        public ActionResult Index(string SearchString)
        {
            int res = 0;

            int DC = MvcApplication.CurrentDC();

            #region comment
            //var ViewModel = new ApplicationView();

            //ViewModel.ApplicationMds = db.Application
            //.Include(a => a.Person.Select(p=>p.BarcodePerson))
            //.Include(a => a.Equipment.Select(e=>e.BarcodeEquipment))
            //.Where(a => a.SetTime == new DateTime(2017, 1, 1));
            #endregion

            //if(System.Security.Principal.WindowsIdentity.GetCurrent().is)

            //List<ApplicationView> ViewModel =



            var request =
                (from a in db.Application
                 join p in db.Person on new { j1 = a.BarcodePersonGet,
                                              j2 = a.DC } equals
                 new { j1 = p.BarcodePerson,
                       j2 = p.DC }
                 //join e in db.Equipment on
                 //new
                 //{
                 //    JoinProperty1 = a.BarcodeEquipment,
                 //    JoinProperty2 = a.TypeEquipment
                 //}
                 //     equals
                 //new
                 //{
                 //    JoinProperty1 = e.BarcodeEquipment,
                 //    JoinProperty2 = e.NameEquipment
                 //}
                 where a.SetTime == new DateTime(2017, 1, 1) && a.DC == DC

                 select new ApplicationView
            {
                BarcodePersonGet = a.BarcodePersonGet,
                NamePersonGet = p.NamePerson,
                BarcodeEquipment = a.BarcodeEquipment,
                NameEquipment = a.TypeEquipment,     //.NameEquipment,
                GetTime = a.GetTime,
                SetTime = a.SetTime,
                Comment = a.Comment,
                DC = a.DC
            });

            if ((!String.IsNullOrEmpty(SearchString)) && (int.TryParse(SearchString, out res)))

            {
                request = request.Where(b => b.BarcodeEquipment == res);
            }


            List <ApplicationView> ViewModel = request.ToList();



            #region roleCom
            //string property = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
            //string property = System.Security.Principal.WindowsIdentity.GetCurrent().Groups;

            //string[] arr = Roles.GetRolesForUser();
            #endregion

            #region stProc
            //var storedProcess = db.Database.ExecuteSqlCommand("TEST_APP_PROCEDURE @ID = {0}",2);
            #endregion

            return(View(ViewModel));
        }
コード例 #19
0
        public ActionResult Create([Bind(Include = "BarcodePersonGet,BarcodeEquipment,TypeEquipment,cbNew")] App_ApplicationModels applicationGet, bool cbNew)
        //public ActionResult Create(int barcodePerson,int  barcodeEquipment)
        {
            if (!cbNew)
            {
                ModelState.AddModelError("BarcodeEquipment", "Проверьте, что оборудование рабочее");
                return(View(applicationGet));
            }

            //Кодирование!
            if (convertTo(applicationGet.BarcodePersonGet) > 1)
            {
                applicationGet.BarcodePersonGet = convertTo(applicationGet.BarcodePersonGet);
            }

            else
            {
                ModelState.AddModelError("BarcodePersonGet", "Ошибка сканирования");
                return(View(applicationGet));
            }


            if (!ExistingEquipment(applicationGet.BarcodeEquipment, applicationGet.TypeEquipment))
            {
                ModelState.AddModelError("BarcodeEquipment", "Этого оборудование нет в списке");
                return(View(applicationGet));
            }

            if (!ExistingPerson(applicationGet.BarcodePersonGet))
            {
                ModelState.AddModelError("BarcodePersonGet", "Этого сотрудника нет в списке");
                return(View(applicationGet));
            }

            if (ExistingApp(applicationGet.BarcodeEquipment, applicationGet.TypeEquipment))
            {
                ModelState.AddModelError("BarcodeEquipment", "Это оборудование уже выдано");
                return(View(applicationGet));
            }

            //applicationGet.BarcodePersonSet = 2;



            int DC = MvcApplication.CurrentDC();

            try
            {
                if (ModelState.IsValid)
                {
                    applicationGet.GetTime = DateTime.Now;
                    applicationGet.SetTime = new DateTime(2017, 1, 1);
                    applicationGet.UserGet = User.Identity.Name.ToString().Replace("HCLASS\\", "");
                    applicationGet.DC      = DC;
                    //applicationGet.Person = new List<PersonModels>();
                    //applicationGet.Equipment = new List<EquipmentModels>();
                    //PersonModels person = db.Person.Where(p => p.BarcodePerson == applicationGet.BarcodePersonGet).First();
                    //applicationGet.Person.Add(person);
                    //EquipmentModels equipment = db.Equipment.Where(e => e.BarcodeEquipment == applicationGet.BarcodeEquipment).First();
                    //applicationGet.Equipment.Add(equipment);
                    //applicationGet.BarcodePersonSet = 0;
                    db.Application.Add(applicationGet);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.)
                ModelState.AddModelError("NotValid", "Невозможно сохранить. Попробуйте снова, если проблема повторится, напишите на Problems.");
            }

            return(View(applicationGet));
        }