Пример #1
0
        public ActionResult Create([Bind(Include = "ArsId,ArsCodigo,ArsNombre,ArsActivo,InstitucionId,ArsUsuarioRegistra,ArsFechaRegistro,ArsUsuarioModifica,ArsFechaModifica")] Ars ars)
        {
            if (ModelState.IsValid)
            {
                db.Ars.Add(ars);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(ars));
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "SupplierID,rowguid,Name,Code,CompanyName,NRC,NIT,CreationDate,CreatedBy,ModifiedDate,ModifiedBy")] Supplier supplier)
        {
            if (ModelState.IsValid)
            {
                db.Supplier.Add(supplier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(supplier));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "ComponentID,Code,Description,ComponentCategoryID,UomID,CustomerID,CustomerCode,CountryOfOrigin,SupplierID,SupplierCode,Description2,PurchasingPrice,PurchasingTerms,ListPrice,HtsID,SacID,IsActive,DiscontinuedDate,CreationDate,CreatedBy,ModifiedDate,ModifiedBy,rowguid")] Component component)
        {
            if (ModelState.IsValid)
            {
                db.Component.Add(component);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ComponentCategoryID = new SelectList(db.ComponentCategory, "ComponentCategoryID", "Name", component.ComponentCategoryID);
            ViewBag.CustomerID          = new SelectList(db.Customer, "CustomerID", "CreatedBy", component.CustomerID);
            ViewBag.SupplierID          = new SelectList(db.Supplier, "SupplierID", "Name", component.SupplierID);
            ViewBag.UomID = new SelectList(db.UnitMeasure, "UomID", "Code", component.UomID);
            return(View(component));
        }
Пример #4
0
 public ActionResult Create([Bind(Include = "CustomerID,Name,Code,CompanyName,NRC,NIT")] Customer customer)
 {
     customer.CreationDate = DateTime.Now.Date;
     customer.CreatedBy    = User.Identity.GetUserId();
     customer.rowguid      = Guid.NewGuid();
     if (ModelState.IsValid)
     {
         db.Customer.Add(customer);
         var item = from a in db.Customer
                    where a.Name == customer.Name || a.NIT == customer.NIT || a.NRC == customer.NRC
                    select a;
         if (item.Count() == 0)
         {
             try
             {
                 db.SaveChanges();
                 TempData["ResultMessage"] = "Data saved correctly";
                 TempData["ResultType"]    = "S";
                 return(View("Index"));
             }
             catch (Exception ex)
             {
                 TempData["ResultMessage"] = "Fail while saving data. " + ex.Message;
                 TempData["ResultType"]    = "E";
                 return(View(customer));
             }
         }
         else
         {
             TempData["ResultMessage"] = "Color " + customer.Name + " already exist in the system";
             TempData["ResultType"]    = "E";
             return(View(customer));
         }
     }
     else
     {
         TempData["ResultMessage"] = "Data are not valid";
         TempData["ResultType"]    = "W";
         return(View(customer));
     }
 }
Пример #5
0
        public ActionResult CategoryCreate([Bind(Include = "Name,Description")] ComponentCategory category)
        {
            category.CreationDate = DateTime.Now.Date;
            category.CreatedBy    = User.Identity.GetUserId();
            category.rowguid      = Guid.NewGuid();

            if (ModelState.IsValid)
            {
                db.ComponentCategory.Add(category);
                var item = from a in db.ComponentCategory
                           where a.Name == category.Name
                           select a;
                if (item.Count() == 0)
                {
                    try
                    {
                        db.SaveChanges();
                        TempData["ResultMessage"] = "Data saved correctly";
                        TempData["ResultType"]    = "S";
                    }
                    catch (Exception ex)
                    {
                        TempData["ResultMessage"] = "Fail while saving data. " + ex.Message;
                        TempData["ResultType"]    = "E";
                    }
                }
                else
                {
                    TempData["ResultMessage"] = "Color " + category.Name + " already exist in the system";
                    TempData["ResultType"]    = "E";
                }
            }
            else
            {
                TempData["ResultMessage"] = "Data are not valid";
                TempData["ResultType"]    = "W";
            }
            return(RedirectToAction("CategoryIndex"));
        }
Пример #6
0
 public ActionResult ColorCreate([Bind(Include = "Name, Description")] Colors color)
 {
     color.ModifiedDate = DateTime.Now.Date;
     if (ModelState.IsValid)
     {
         db.Colors.Add(color);
         var item = from a in db.Colors
                    where a.Name == color.Name
                    select a;
         if (item.Count() == 0)
         {
             try
             {
                 db.SaveChanges();
                 TempData["ResultMessage"] = "Data saved correctly";
                 TempData["ResultType"]    = "S";
             }
             catch (Exception ex)
             {
                 TempData["ResultMessage"] = "Fail while saving data. " + ex.Message;
                 TempData["ResultType"]    = "E";
             }
         }
         else
         {
             TempData["ResultMessage"] = "Color " + color.Name + " already exist in the system";
             TempData["ResultType"]    = "E";
             //return PartialView("_ColorCreate", color);
         }
     }
     else
     {
         TempData["ResultMessage"] = "Data are not valid";
         TempData["ResultType"]    = "W";
         //return PartialView("_ColorCreate", color);
     }
     return(RedirectToAction("ColorIndex"));
 }
Пример #7
0
        public ActionResult SavePermission(string query, string qtype)
        {
            string fquery = "{\"PERMISSION\":" + query + "}";

            if (qtype == "r")
            {
                /*DELETING ROWS*/
                var    data   = Newtonsoft.Json.Linq.JObject.Parse(fquery);
                String roleId = Convert.ToString(data["PERMISSION"][0]["RoleID"]);

                var rows = from r in db.Permission
                           where r.RoleID == roleId
                           select r;
                foreach (var row in rows)
                {
                    db.Permission.Remove(row);
                }
                db.SaveChanges();

                int    menu;
                string role;
                for (int i = 0; i < data["PERMISSION"].Count(); i++)
                {
                    menu = (int)data["PERMISSION"][i]["MenuID"];
                    role = (string)data["PERMISSION"][i]["RoleID"];
                    db.Permission.Add(new Permission {
                        MenuID = menu, RoleID = role
                    });
                }
                try
                {
                    db.SaveChanges();
                    TempData["ResultMessage"] = "Los datos se guardaron correctamente";
                    TempData["ResultType"]    = "S";
                }
                catch (Exception ex)
                {
                    TempData["ResultMessage"] = "Error al guardar los datos! " + ex.Message;
                    TempData["ResultType"]    = "E";
                }
            }
            if (qtype == "u")
            {
                /*DELETING ROWS*/
                var    data   = Newtonsoft.Json.Linq.JObject.Parse(fquery);
                String userId = Convert.ToString(data["PERMISSION"][0]["UserID"]);
                var    rows   = from r in db.CustomPermission
                                where r.UserID == userId
                                select r;
                foreach (var row in rows)
                {
                    db.CustomPermission.Remove(row);
                }
                db.SaveChanges();

                int    menu;
                string user;
                for (int i = 0; i < data["PERMISSION"].Count(); i++)
                {
                    menu = (int)data["PERMISSION"][i]["MenuID"];
                    user = (String)data["PERMISSION"][i]["UserID"];
                    db.CustomPermission.Add(new CustomPermission {
                        MenuID = menu, UserID = user
                    });
                }
                try
                {
                    db.SaveChanges();
                    TempData["ResultMessage"] = "Los datos se guardaron correctamente";
                    TempData["ResultType"]    = "S";
                }
                catch (Exception ex)
                {
                    TempData["ResultMessage"] = "Error al guardar los datos! " + ex.Message;
                    TempData["ResultType"]    = "E";
                }
            }


            return(RedirectToAction("Index"));
        }