Esempio n. 1
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"));
        }
Esempio n. 2
0
        public ActionResult Edit(int Id)
        {
            int DC = MvcApplication.CurrentDC();

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

            return(View(person));
        }
Esempio n. 3
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));
        }
Esempio n. 4
0
        public ActionResult ViewPerson(int?Id)

        {
            App_PersonModels person = new App_PersonModels();

            if (Id != null & db.Person.Any(a => a.BarcodePerson == Id))
            {
                person = db.Person.First(a => a.BarcodePerson == Id);
            }

            else
            {
                person.NamePerson = "";
            }

            return(PartialView(person));
        }
Esempio n. 5
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());
        }