Ejemplo n.º 1
0
        public ActionResult Create(FormCollection collection)
        {
            if (!Access.HasAccess(62))
            {
                System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary();
                route.Add("err", "Нет доступа!");
                return(RedirectToAction("Error", "Home", route));
            }
            try {
                Matmodel model = new Matmodel();
                model.Name       = collection["Name"];
                model.Partnumber = collection["Partnumber"];
                model.Capacity   = Convert.ToInt32(collection["Capacity"]);
                model.Price      = Convert.ToInt32(collection["Price"]);
                model.Vendor     = (new Vendor()).GetById(Convert.ToInt32(collection["VendorID"]));
                model.Typedev    = (new Typedev()).GetById(Convert.ToInt32(collection["TypedevID"]));
                model.Save(model);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;
                return(View());
            }
        }
Ejemplo n.º 2
0
        public ActionResult Compatibility(int ID, FormCollection collection)
        {
            if (!Access.HasAccess(61))
            {
                System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary();
                route.Add("err", "Нет доступа!");
                return(RedirectToAction("Error", "Home", route));
            }
            Matmodel model = new Matmodel();

            model = model.GetById(ID);

            string IDs = collection["DevmodelSelections"];

            model.Devmodels.Clear();
            model.Update(model);

            foreach (string item in IDs.Split(','))
            {
                model.Devmodels.Add((new Devmodel()).GetById(Convert.ToInt32(item)));
            }

            model.Update(model);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public ActionResult ShowMaterials(int id, int MatmodelID)
        {
            if (!Access.HasAccess(66))
            {
                System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary();
                route.Add("err", "Нет доступа!");
                return(RedirectToAction("Error", "Home", route));
            }
            ViewBag.StoreID    = id;
            ViewBag.MatmodelID = MatmodelID;
            Matmodel theMatmodel = (new Matmodel()).GetById(MatmodelID);

            ViewBag.Matmodel  = theMatmodel;
            ViewBag.Stores    = (new Store()).GetAll();
            ViewBag.Devices   = (new Device()).GetAll();
            ViewBag.Rooms     = (new Room()).GetAll();
            ViewBag.Materials = (new Material()).GetAll("MAT_MODEL_ID=" + ViewBag.MatmodelID);
            List <Material> theMaterials1 = (new Material()).GetAll("MAT_MODEL_ID=" + ViewBag.MatmodelID + " AND REPOSITORY_ID=" + ViewBag.StoreID + " AND STATUS_ID=1");

            ViewBag.Materials1  = theMaterials1;
            ViewBag.Materials22 = ((List <Material>)ViewBag.Materials).Where(x => x.StatusID == 22).Where(x => x.Store.ID == ViewBag.StoreID);
            ViewBag.Materials3  = ((List <Material>)ViewBag.Materials).Where(x => x.StatusID == 3).Where(x => x.Store.ID == ViewBag.StoreID);
            ViewBag.Mathistory  = (new Mathistory()).GetAll("STORE_ID=" + ViewBag.StoreID + " AND STATUS_ID=2");
            return(View());
        }
Ejemplo n.º 4
0
        public JsonResult IsMatmodelName_Available(string Name)
        {
            Matmodel model      = new Matmodel();
            int      modelCount = model.GetAll("NAME = '" + Name + "'").Count;

            if (modelCount > 0)
            {
                string suggestedUID = String.Format(CultureInfo.InvariantCulture,
                                                    "Расходный материал {0} уже существует.", Name);
                return(Json(suggestedUID, JsonRequestBehavior.AllowGet));
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public ActionResult Edit(int ID)
        {
            if (!Access.HasAccess(63))
            {
                System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary();
                route.Add("err", "Нет доступа!");
                return(RedirectToAction("Error", "Home", route));
            }
            Matmodel model = new Matmodel();

            model = model.GetById(ID);
            return(View(model));
        }
Ejemplo n.º 6
0
        //
        // GET: /Matmodel/

        public ActionResult Index()
        {
            if (!Access.HasAccess(61))
            {
                System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary();
                route.Add("err", "Нет доступа!");
                return(RedirectToAction("Error", "Home", route));
            }
            List <Matmodel> theListMatmodel = new List <Matmodel>();
            Matmodel        theMatmodel     = new Matmodel();

            theListMatmodel = (List <Matmodel>)theMatmodel.GetAll();

            return(View(theListMatmodel));
        }
Ejemplo n.º 7
0
 public ActionResult Delete(int ID)
 {
     if (!Access.HasAccess(65))
     {
         System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary();
         route.Add("err", "Нет доступа!");
         return(RedirectToAction("Error", "Home", route));
     }
     try
     {
         Matmodel model = new Matmodel();
         model = model.GetById(ID);
         model.Delete(model);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         ViewBag.Error = ex.Message;
         return(View());
     }
 }