public string Insert(int TrainID, string Value) { TrainDailyDetail tdd = new TrainDailyDetail { TRAIN_ID = TrainID, TDD_DAILY = Value }; db.TrainDailyDetails.InsertOnSubmit(tdd); try { db.SubmitChanges(); return Constants.INSERT_SUCCESS; } catch (Exception ex) { return ex.Message; } }
public bool Update(int DailyID, TrainDailyDetail trainDailyDetail) { var result = from tdd in db.TrainDailyDetails where tdd.TDD_ID == DailyID select tdd; if (result.Any()) { result.Single().TDD_DAILY = trainDailyDetail.TDD_DAILY; try { db.SubmitChanges(); return true; } catch (Exception ex) { } } return true; }
public ActionResult Edit(FormCollection Form) { string result; TrainDailyDetail tdd = tdm.GetOneByID(int.Parse(Form["ScheduleID"])); ViewData["Data"] = tdd; string DailyValue = ""; try { string[] days = Form["DailyValue"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string day in days) { DailyValue += day; } } catch { ViewData["Error"] = "Please select at least one day!"; return View(); } try { TrainDailyDetail td = new TrainDailyDetail { TDD_DAILY = DailyValue, TDD_ID = tdd.TDD_ID, TRAIN_ID = tdd.TRAIN_ID }; tdm.Update(tdd.TDD_ID, td); } catch (Exception ex) { result = ex.Message; } return RedirectToAction("Index"); }
partial void DeleteTrainDailyDetail(TrainDailyDetail instance);
partial void UpdateTrainDailyDetail(TrainDailyDetail instance);
partial void InsertTrainDailyDetail(TrainDailyDetail instance);
private void detach_TrainDailyDetails(TrainDailyDetail entity) { this.SendPropertyChanging(); entity.TrainDetail = null; }