Exemple #1
0
 public ActionResult Create(SubCodes model)
 {
     try
     {
         if (Convert.ToString(Session["userType"]) == "3")
         {
             ViewBag.Code = new SelectList(context.DelayCode, "DelayCodeId", "DelayName");
             // TODO: Add insert logic here
             if (ModelState.IsValid)
             {
                 context.SubCodes.Add(model);
                 context.SaveChanges();
                 return(RedirectToAction("Index", "Config"));
             }
             else
             {
                 return(RedirectToAction("Index"));
             }
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(WorkOrden orden)
 {
     try
     {
         ViewBag.Catalog = new SelectList(context.Catalog, "CatalogId", "CatalogDescrip");
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             if (ValidBatch(orden.BatchOrden) == false)
             {
                 context.WorkOrden.Add(orden);
                 context.SaveChanges();
                 return(RedirectToAction("Index"));
             }
             else
             {
                 ViewBag.Catalog = new SelectList(context.Catalog, "CatalogId", "CatalogDescrip");
                 this.ModelState.AddModelError(string.Empty, "Esta orden ya se encuentra registrada.");
                 return(View());
             }
         }
         else
         {
             ViewBag.Catalog = new SelectList(context.Catalog, "CatalogId", "CatalogDescrip");
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Create(Catalog catalog, HttpPostedFileBase image)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    ViewBag.Family = new SelectList(context.FamilyProduct, "FamilyProductId", "nameFamily");
                    string img = "";
                    if (image != null)
                    {
                        //catalog.image = new byte[image.ContentLength];
                        //image.InputStream.Read(catalog.image, 0, image.ContentLength);
                        img = System.IO.Path.GetFileName(image.FileName);
                        string physicalPath = Server.MapPath("~/fonts/images/" + img);

                        image.SaveAs(physicalPath);
                        catalog.image = img;
                    }
                    context.Catalog.Add(catalog);
                    context.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.Family = new SelectList(context.FamilyProduct, "FamilyProductId", "nameFamily");
                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }
Exemple #4
0
        public ActionResult Create(Officer officer)
        {
            if (ModelState.IsValid)
            {
                db.BoosterOfficers.Add(officer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(officer));
        }
Exemple #5
0
        public ActionResult Create(Resource resource)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Resources"));
            }
            if (ModelState.IsValid)
            {
                db.Resources.Add(resource);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(resource));
        }
        public ActionResult Create(Meet meet)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Schedule"));
            }
            if (ModelState.IsValid)
            {
                db.Meets.Add(meet);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(meet));
        }
Exemple #7
0
        public ActionResult Create(Mark mark)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Stats"));
            }
            if (ModelState.IsValid)
            {
                db.Marks.Add(mark);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mark));
        }
        public ActionResult Create(BoosterEvent boosterevent)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Boosters"));
            }
            if (ModelState.IsValid)
            {
                db.Events.Add(boosterevent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(boosterevent));
        }
        public ActionResult Create(Coach coach)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Staff"));
            }
            if (ModelState.IsValid)
            {
                db.Coaches.Add(coach);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(coach));
        }
        public ActionResult Create(Article article)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("News"));
            }
            if (ModelState.IsValid)
            {
                article.PostedDate = DateTime.UtcNow.AddHours(-7);
                db.Articles.Add(article);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(article));
        }
 public ActionResult Create(FamilyProduct model)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             context.FamilyProduct.Add(model);
             context.SaveChanges();
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(Employee_type emp)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             context.Employee_type.Add(emp);
             context.SaveChanges();
             return(RedirectToAction("Index", "Config"));
         }
         else
         {
             return(View(emp));
         }
     }
     catch
     {
         return(View());
     }
 }
Exemple #13
0
 public ActionResult ApproveRequest(int id)
 {
     try
     {
         if (Convert.ToString(Session["userType"]) == "3")
         {
             var model = context.Users.Find(id);
             model.active = true;
             context.SaveChanges();
             return(RedirectToAction("ListNewRequest"));
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     catch
     {
         return(View());
     }
 }
Exemple #14
0
 public ActionResult Create(DelayCode code)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             context.DelayCode.Add(code);
             context.SaveChanges();
             return(RedirectToAction("Index", "Config"));
         }
         else
         {
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }
Exemple #15
0
        public ActionResult Create(Users user)
        {
            try
            {
                //user.Area = null;

                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    if (ValidUserExists(user.username) == true && UserIsNotRegister(user.username) == false)
                    {
                        ViewBag.Employee_type = new SelectList(context.Employee_type, "Employee_typeId", "NameType");
                        ViewBag.Area          = new SelectList(context.Area, "AreaId", "AreaName");
                        user.active           = false;
                        user.notify           = false;
                        context.Users.Add(user);
                        context.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ViewBag.Employee_type = new SelectList(context.Employee_type, "Employee_typeId", "NameType");
                        ViewBag.Area          = new SelectList(context.Area, "AreaId", "AreaName");
                        this.ModelState.AddModelError(string.Empty, "El usuario no existe dentro de los registros, o ya fue registrado.");
                        return(View());
                    }
                }
                else
                {
                    ViewBag.Employee_type = new SelectList(context.Employee_type, "Employee_typeId", "NameType");
                    ViewBag.Area          = new SelectList(context.Area, "AreaId", "AreaName");
                    return(View(user));
                }
            }
            catch
            {
                return(View());
            }
        }
 public ActionResult Create(DelayWork delay)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             ViewBag.DelayCode = new SelectList(context.DelayCode, "DelayCodeId", "DelayName");
             ViewBag.WorkOrden = new SelectList(context.WorkOrden, "WorkOrdenId", "BatchOrden");
             ViewBag.Users     = new SelectList(context.Users, "UsersId", "username");
             context.DelayWork.Add(delay);
             context.SaveChanges();
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(AreaPlus model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             context.AreaPlus.Add(model);
             context.SaveChanges();
             return(RedirectToAction("Index", "Users"));
         }
         else
         {
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult New(DelayComment model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             context.DelayComment.Add(model);
             context.SaveChanges();
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }
Exemple #19
0
 public ActionResult Create(OrdenComment model)
 {
     try
     {
         model.UsersId = (int)Session["userId"];
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             context.OrdenComment.Add(model);
             context.SaveChanges();
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             return(PartialView("Index", "Area_Orden"));
         }
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(DeliveryOrder model)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             context.Entry(model).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
             int area = (int)Session["temparea"];
             int id   = (int)Session["tempid"];
             return(RedirectToAction("FinishOrden", "Area_Orden", new { id = id, areaid = area }));
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     catch (Exception ex)
     {
         var x = ex.Message;
         return(View());
     }
 }
        public ActionResult FinishOrden(int id, int areaid)
        {
            Session["temparea"] = 0;
            Session["tempid"]   = 0;
            var check = context.DelayWork.Where(d => d.WorkOrdenId == id).Where(d => d.dateFinish == null).ToList();

            if (check.ToList().Count == 0)
            {
                var delay = from d in context.DelayWork
                            where d.WorkOrdenId == id && d.dateFinish == null
                            select d;
                var lstdelay = delay.ToList();
                if (lstdelay.Count < 1)
                {
                    Session["stop"] = null;
                    int area = areaid;
                    var ar   = from u in context.Area
                               where u.orden == area
                               select u;
                    foreach (var item in ar.ToList())
                    {
                        area = (int)item.AreaId;
                    }
                    var up = from w in context.Area_Orden
                             where w.WorkOrdenId == id && w.AreaId == area
                             select w;
                    foreach (Area_Orden a in up)
                    {
                        a.dateFinish = DateTime.Now;
                        a.notify     = true;
                        //finish = a.AreaId;
                    }
                    if (area == 6)
                    {
                        var upOrden = from w in context.WorkOrden
                                      where w.WorkOrdenId == id
                                      select w;

                        foreach (WorkOrden w in upOrden)
                        {
                            w.dateFinish = DateTime.Now;
                        }
                    }
                    context.SaveChanges();
                    //if (area != 6)
                    //{
                    //    int areanext = 0;
                    //    string to="";
                    //    int areaRoot = (int)Session["userAreaId"] + 1;
                    //    var an = from a in context.Area
                    //             where a.orden == areaRoot
                    //             select a;
                    //    foreach(var item in an.ToList())
                    //    {
                    //        areanext = (int)item.AreaId;
                    //    }
                    //    var emails = from u in context.Users
                    //                 where u.AreaId == areanext
                    //                 select u;
                    //    int i = 1;
                    //    foreach(var item in emails.ToList())
                    //    {
                    //        if (i == emails.ToList().Count)
                    //        {
                    //            to += item.emailuser;
                    //        }
                    //        else
                    //        {
                    //            to += item.emailuser + ",";
                    //        }
                    //    }
                    //    sendEmail("Pruena", to);
                    //}

                    return(PartialView("_closeWork"));
                    //return RedirectToAction("Index","Home");
                    //return JavaScript("window.location.reload();");
                    //return Content("<script language='javascript' type='text/javascript'>window.location.reload();</script>");
                }
                else
                {
                    ViewBag.Stop    = "No puede finalizar la orden ya que cuenta con un retraso abierto, debe ser cerrado antes.";
                    Session["stop"] = "No puede finalizar la orden ya que cuenta con un retraso abierto, debe ser cerrado antes.";
                    return(RedirectToAction("Index"));
                    //return Content("<script language='javascript' type='text/javascript'>alert('No puede finalizar la orden ya que cuenta con un retraso abierto, debe ser cerrado antes.');</script>");
                }
            }
            else
            {
                //this.ModelState.AddModelError(string.Empty, "No puede finalizar la orden ya que cuenta con un retraso abierto, debe ser cerrado antes.");
                Session["stop"] = "No puede finalizar la orden ya que cuenta con un retraso abierto, debe ser cerrado antes.";
                return(RedirectToAction("Index", "Home"));
            }
        }
Exemple #22
0
        public ActionResult StartOrden(int id, int fromarea)
        {
            int orden = id;
            int area  = fromarea;
            //var getOrden = from w in context.WorkOrden
            //            where w.BatchOrden == id.ToString()
            //            select w;
            //var lstOrden = getOrden.ToList();
            //foreach(var d in lstOrden)
            //{
            //    orden = d.WorkOrdenId;
            //}
            int user = Convert.ToInt32(Session["userId"]);

            //area = (int)Session["userAreaId"];


            if (area == 1)
            {
                var up = from w in context.WorkOrden
                         where w.WorkOrdenId == id
                         select w;
                foreach (WorkOrden wo in up)
                {
                    wo.dateStart = DateTime.Now;
                }
                DeliveryOrder delivery = new DeliveryOrder();
                delivery.WorkOrdenID = id;
                context.DeliveryOrder.Add(delivery);
            }
            var ar = from a in context.Area
                     where a.orden == area
                     select a;

            foreach (var item in ar.ToList())
            {
                area = (int)item.AreaId;
            }
            Area_Orden ord = new Area_Orden()
            {
                AreaId      = area,
                WorkOrdenId = orden,
                dateStart   = DateTime.Now,
                runOrden    = true,
                notify      = false
            };

            area = fromarea;
            if (area != 1)
            {
                var s**t = from a in context.Area_Orden
                           join b in context.Area on a.AreaId equals b.AreaId
                           where a.WorkOrdenId == id && b.orden == (area - 1)
                           select a;
                var slutlst = s**t.ToList();
                foreach (Area_Orden a in s**t)
                {
                    a.runOrden = false;
                }
            }
            context.Area_Orden.Add(ord);
            context.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public void CommitChanges()
 {
     Context.SaveChanges();
 }