Beispiel #1
0
        public ActionResult EditTrailer([Bind(Include = "TrailerNumber,DOTDate,TrailerStatus,Leased,InsuranceCard,Insured,Title,PlateNumber,VinNumber,Manufacturer,ManufactureYear,TrailerLocation,TrailerLength,Issues,DateModified")] TrailerList UpdatedTrailer)
        {
            using (TrailerEntities db = new TrailerEntities())
            {
                TrailerList trailer = db.TrailerLists.FirstOrDefault(t => t.TrailerNumber == UpdatedTrailer.TrailerNumber);

                try
                {
                    ActiveTrailerList editActiveTrailer = db.ActiveTrailerLists.FirstOrDefault(t => t.TrailerNumber == UpdatedTrailer.TrailerNumber);
                    editActiveTrailer.TrailerLocation = UpdatedTrailer.TrailerLocation;
                }
                catch {}

                trailer.DOTDate         = UpdatedTrailer.DOTDate;
                trailer.TrailerStatus   = UpdatedTrailer.TrailerStatus;
                trailer.Leased          = UpdatedTrailer.Leased;
                trailer.InsuranceCard   = UpdatedTrailer.InsuranceCard;
                trailer.Insured         = UpdatedTrailer.Insured;
                trailer.Title           = UpdatedTrailer.Title;
                trailer.PlateNumber     = UpdatedTrailer.PlateNumber;
                trailer.VinNumber       = UpdatedTrailer.VinNumber;
                trailer.Manufacturer    = UpdatedTrailer.Manufacturer;
                trailer.ManufactureYear = UpdatedTrailer.ManufactureYear;
                trailer.TrailerLength   = UpdatedTrailer.TrailerLength;
                trailer.TrailerLocation = UpdatedTrailer.TrailerLocation;
                trailer.Issues          = UpdatedTrailer.Issues;
                trailer.DateModified    = UpdatedTrailer.DateModified;

                db.SaveChanges();
                return(RedirectToAction(actionName: "TrailerList", controllerName: "Trailer"));
            }
        }
Beispiel #2
0
        public ActionResult EditActiveTrailer([Bind(Include = "TrailerGUID,TrailerNumber,TrailerStatus,LoadStatus,Customer,OrderDate,OrderNumber,LocationStatus,TrailerLocation,Notes,Tags,DateModified,LastModifiedBy")] ActiveTrailerList UpdatedTrailer)
        {
            using (TrailerEntities db = new TrailerEntities())
            {
                ActiveTrailerList trailer = db.ActiveTrailerLists.FirstOrDefault(t => t.TrailerNumber == UpdatedTrailer.TrailerNumber);
                if (!constant.checkIfEqual(trailer, UpdatedTrailer))
                {
                    trailer.DateModified = DateTime.Now.ToString("yyyy-MM-dd");
                }

                TrailerList trailerEdit = db.TrailerLists.FirstOrDefault(t => t.TrailerNumber == UpdatedTrailer.TrailerNumber);

                if (trailer.TrailerStatus != constant.TRAILER_STATUS_NEED_EMPTY && UpdatedTrailer.TrailerStatus == constant.TRAILER_STATUS_NEED_EMPTY)
                {
                    SortList newSort = new SortList()
                    {
                        TrailerNumber = UpdatedTrailer.TrailerNumber,
                        Customer      = UpdatedTrailer.Customer,
                        OrderNumber   = UpdatedTrailer.OrderNumber,
                        SortType      = UpdatedTrailer.Notes,
                        LoadStatus    = UpdatedTrailer.LoadStatus,
                        DateArrived   = DateTime.Now.ToString("yyyy-MM-dd"),
                        Status        = "NEW",
                    };
                    db.SortLists.Add(newSort);
                }

                if (trailerEdit != null)
                {
                    trailerEdit.TrailerLocation = UpdatedTrailer.TrailerLocation;
                }

                trailer.TrailerStatus  = UpdatedTrailer.TrailerStatus;
                trailer.LoadStatus     = UpdatedTrailer.LoadStatus;
                trailer.Customer       = UpdatedTrailer.Customer;
                trailer.OrderDate      = UpdatedTrailer.OrderDate;
                trailer.OrderNumber    = UpdatedTrailer.OrderNumber;
                trailer.LocationStatus = UpdatedTrailer.LocationStatus;

                if (UpdatedTrailer.TrailerStatus == constant.TRAILER_STATUS_DELIVERED)
                {
                    trailer.TrailerLocation = UpdatedTrailer.Customer;
                }
                else
                {
                    trailer.TrailerLocation = UpdatedTrailer.TrailerLocation;
                }

                trailer.Notes          = UpdatedTrailer.Notes;
                trailer.Tags           = UpdatedTrailer.Tags;
                trailer.LastModifiedBy = Session["name"].ToString();

                db.SaveChanges();
                return(RedirectToAction(actionName: "ActiveTrailerList", controllerName: "Trailer"));
            }
        }
Beispiel #3
0
        public ActionResult CreateTrailer([Bind(Include = "TrailerNumber,DOTDate,TrailerStatus,Leased,InsuranceCard,Insured,Title,PlateNumber,VinNumber,Manufacturer,ManufactureYear,TrailerLocation,TrailerLength,Issues,DateModified")] TrailerList createTrailer)
        {
            //add new trailer to database
            using (TrailerEntities db = new TrailerEntities())
            {
                if (ModelState.IsValid)
                {
                    //create trailer
                    TrailerList trailer = new TrailerList()
                    {
                        TrailerNumber   = createTrailer.TrailerNumber,
                        DOTDate         = createTrailer.DOTDate,
                        TrailerStatus   = createTrailer.TrailerStatus,
                        Leased          = createTrailer.Leased,
                        InsuranceCard   = createTrailer.InsuranceCard,
                        Insured         = createTrailer.Insured,
                        Title           = createTrailer.Title,
                        PlateNumber     = createTrailer.PlateNumber,
                        VinNumber       = createTrailer.VinNumber,
                        Manufacturer    = createTrailer.Manufacturer,
                        ManufactureYear = createTrailer.ManufactureYear,
                        TrailerLocation = createTrailer.TrailerLocation,
                        TrailerLength   = createTrailer.TrailerLength,
                        Issues          = createTrailer.Issues,
                        DateModified    = createTrailer.DateModified
                    };

                    //check to make sure trailer number does not exist already
                    if (db.TrailerLists.Any(t => t.TrailerNumber == trailer.TrailerNumber))
                    {
                        //duplicate trailer number
                        ModelState.AddModelError("TrailerNumber", "Trailer number already exists");
                        return(View());
                    }
                    if (createTrailer.TrailerNumber.Contains(" "))
                    {
                        ModelState.AddModelError("TrailerNumber", "Trailer number must not contain any spaces");
                        return(View());
                    }

                    db.TrailerLists.Add(trailer);
                    db.SaveChanges();
                    return(RedirectToAction(actionName: "TrailerList", controllerName: "Trailer"));
                }
                return(View());
            }
        }
Beispiel #4
0
        public ActionResult CreateInactiveTrailer(string trailerNumber)
        {
            if (Session["username"] == null)
            {
                return(RedirectToAction(actionName: "SignIn", controllerName: "Users"));
            }
            else
            {
                using (TrailerEntities db = new TrailerEntities())
                {
                    if (Convert.ToInt32(Session["permission"]) < constant.PERMISSION_EDIT)
                    {
                        return(RedirectToAction(actionName: "InsufficientPermissions", controllerName: "Error"));
                    }
                    else
                    {
                        TrailerList trailer = db.TrailerLists.FirstOrDefault(t => t.TrailerNumber == trailerNumber);

                        InactiveTrailerList trailerEdit = new InactiveTrailerList()
                        {
                            TrailerNumber   = trailer.TrailerNumber,
                            DOTDate         = trailer.DOTDate,
                            TrailerStatus   = trailer.TrailerStatus,
                            Leased          = trailer.Leased,
                            InsuranceCard   = trailer.InsuranceCard,
                            Insured         = trailer.Insured,
                            Title           = trailer.Title,
                            PlateNumber     = trailer.PlateNumber,
                            VinNumber       = trailer.VinNumber,
                            Manufacturer    = trailer.Manufacturer,
                            ManufactureYear = trailer.ManufactureYear,
                            TrailerLength   = trailer.TrailerLength,
                            Issues          = trailer.Issues,
                            DateModified    = trailer.DateModified
                        };
                        db.InactiveTrailerLists.Add(trailerEdit);
                        db.SaveChanges();
                        return(RedirectToAction(actionName: "RemoveFromMasterList", controllerName: "Trailer", routeValues: new { trailerNumber }));
                    }
                }
            }
        }
Beispiel #5
0
        public ActionResult EditTrailer(string trailerNumber)
        {
            if (Session["username"] == null)
            {
                return(RedirectToAction(actionName: "SignIn", controllerName: "Users"));
            }
            else
            {
                if (Convert.ToInt32(Session["permission"]) < constant.PERMISSION_EDIT)
                {
                    return(RedirectToAction(actionName: "InsufficientPermissions", controllerName: "Error"));
                }
                else
                {
                    using (TrailerEntities db = new TrailerEntities())
                    {
                        TrailerList trailer = db.TrailerLists.FirstOrDefault(t => t.TrailerNumber == trailerNumber);

                        return(View(trailer));
                    }
                }
            }
        }