예제 #1
0
        public bool Update(int TrainId, TrainDetail tdl)
        {
            var update = from td in db.TrainDetails
                         where td.TRAIN_ID == TrainId
                         select td;
            if (update.Any()) {
                update.Single().TRAIN_FROM_TO = tdl.TRAIN_FROM_TO;
                update.Single().TRAIN_NAME = tdl.TRAIN_NAME;
                update.Single().TRAIN_NUM_COM_1AC = tdl.TRAIN_NUM_COM_1AC;
                update.Single().TRAIN_NUM_COM_2AC = tdl.TRAIN_NUM_COM_2AC;
                update.Single().TRAIN_NUM_COM_3AC = tdl.TRAIN_NUM_COM_3AC;
                update.Single().TRAIN_NUM_COM_SLEEPER = tdl.TRAIN_NUM_COM_SLEEPER;
                update.Single().TRAIN_NUM_COM_GEN = tdl.TRAIN_NUM_COM_GEN;
                update.Single().TRAIN_TOTAL_COM = tdl.TRAIN_TOTAL_COM;
                update.Single().TRAIN_TYPE = tdl.TRAIN_TYPE;
                try
                {
                    db.SubmitChanges();
                    return true;
                }
                catch (Exception ex) {
                    return false;
                }

            }
            return false;
        }
예제 #2
0
 public String Insert(TrainDetail td)
 {
     db.TrainDetails.InsertOnSubmit(td);
     try
     {
         db.SubmitChanges();
         return Constants.INSERT_SUCCESS;
     }
     catch (Exception ex) {
         return ex.Message;
     }
 }
예제 #3
0
파일: Utils.cs 프로젝트: xuanloc/Projects
 public static int getMaxNumberOfClass(string Compartment, TrainDetail tdd)
 {
     switch (Compartment) {
         case Constants.AC1:
             return Constants.NUMER_OF_1AC_COM * tdd.TRAIN_NUM_COM_1AC;
         case Constants.AC2:
             return Constants.NUMER_OF_2AC_COM * tdd.TRAIN_NUM_COM_2AC;
         case Constants.AC3:
             return Constants.NUMER_OF_3AC_COM * tdd.TRAIN_NUM_COM_3AC;
         case Constants.SLP:
             return Constants.NUMER_OF_SLEEP_COM * tdd.TRAIN_NUM_COM_SLEEPER;
         case Constants.GNR:
             return Constants.NUMER_OF_GEN_COM * tdd.TRAIN_NUM_COM_GEN;
         default: return 0;
     }
 }
예제 #4
0
 public ActionResult Edit(FormCollection Form)
 {
     int TrainId = int.Parse(Form["TrainID"].ToString());
     TrainDetail td = new TrainDetail();
     td.TRAIN_NAME = Form["Name"];
     td.TRAIN_TOTAL_COM = int.Parse(Form["TotalCom"]);
     td.TRAIN_NUM_COM_1AC = int.Parse(Form["1AC"]);
     td.TRAIN_NUM_COM_2AC = int.Parse(Form["2AC"]);
     td.TRAIN_NUM_COM_3AC = int.Parse(Form["3AC"]);
     td.TRAIN_NUM_COM_SLEEPER = int.Parse(Form["Sleeper"]);
     td.TRAIN_NUM_COM_GEN = int.Parse(Form["General"]);
     td.TRAIN_FROM_TO = Form["From"] + "-" + Form["To"];
     td.TRAIN_TYPE = int.Parse(Form["TrainType"]);
     if (tm.Update(TrainId, td))
     {
         return RedirectToAction("Index");
     }
     else {
         ViewData["Error"] = "Can not update this train";
         return View();
     }
 }
예제 #5
0
 public ActionResult Create(FormCollection Form)
 {
     string result;
     try
     {
         TrainDetail td = new TrainDetail();
         td.TRAIN_NAME = Form["Name"];
         td.TRAIN_TOTAL_COM = int.Parse(Form["TotalCom"]);
         td.TRAIN_NUM_COM_1AC = int.Parse(Form["1AC"]);
         td.TRAIN_NUM_COM_2AC = int.Parse(Form["2AC"]);
         td.TRAIN_NUM_COM_3AC = int.Parse(Form["3AC"]);
         td.TRAIN_NUM_COM_SLEEPER = int.Parse(Form["Sleeper"]);
         td.TRAIN_NUM_COM_GEN = int.Parse(Form["General"]);
         td.TRAIN_FROM_TO = Form["From"] + "-" + Form["To"];
         td.TRAIN_TYPE = int.Parse(Form["TrainType"]);
         result = tm.Insert(td);
     }
     catch (Exception ex) {
         result = ex.Message;
     }
     return RedirectToAction("Add", new { msg = result});
 }
예제 #6
0
 partial void DeleteTrainDetail(TrainDetail instance);
예제 #7
0
 partial void UpdateTrainDetail(TrainDetail instance);
예제 #8
0
 partial void InsertTrainDetail(TrainDetail instance);
예제 #9
0
		private void detach_TrainDetails(TrainDetail entity)
		{
			this.SendPropertyChanging();
			entity.TrainTypeDetail = null;
		}