상속: MonoBehaviour
        public ActionResult DeleteConfirmed(decimal id)
        {
            TRAIN tRAIN = db.TRAINs.Find(id);

            db.TRAINs.Remove(tRAIN);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
파일: TrainBOSS.cs 프로젝트: FrameSpark/zd
 public TrainBOSS(PASSANGER p)
 {
     InitializeComponent();
     passanger = p;
     int.TryParse(string.Join("", p.name.Where(c => char.IsDigit(c))), out numberTrain);
     train       = db.getTrainById(db.getIdTrainByNumber(Convert.ToString(numberTrain)));
     type        = db.getTrainTypeById(db.getIdTrainByNumber(Convert.ToString(numberTrain))).type_train;
     label1.Text = "Ваш поезд #" + numberTrain + " /" + type;
 }
 public ActionResult Edit([Bind(Include = "TRAINID,COACH_FIRST,COACH_STANDARD,STATUS,TOTALSEATS")] TRAIN tRAIN)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tRAIN).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tRAIN));
 }
        public ActionResult Create([Bind(Include = "TRAINID,COACH_FIRST,COACH_STANDARD,STATUS,TOTALSEATS")] TRAIN tRAIN)
        {
            if (ModelState.IsValid)
            {
                db.TRAINs.Add(tRAIN);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tRAIN));
        }
        /// <summary>
        /// searches and displays the account in the details view
        /// </summary>
        /// <param name="id"></param> id of the train
        /// <returns></returns>
        // GET: Trains/Details/5
        public ActionResult Details(decimal id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TRAIN tRAIN = db.TRAINs.Find(id);

            if (tRAIN == null)
            {
                return(HttpNotFound());
            }
            return(View(tRAIN));
        }
        /// <summary>
        /// on create button click goes through a validation so the unique id should be generated then returns the id and displays it on the create page
        /// </summary>
        /// <returns></returns>
        // GET: Trains/Create
        public ActionResult Create()
        {
            TRAIN newTrain = new TRAIN();

            var lastTrain = db.TRAINs.OrderByDescending(x => x.TRAINID).FirstOrDefault();

            if (lastTrain == null)
            {
                newTrain.TRAINID = 3001;
            }
            else if (lastTrain.TRAINID != 0)
            {
                newTrain.TRAINID = lastTrain.TRAINID + 1;
            }

            return(View(newTrain));
        }