/// <summary> /// T05_TTRNの新規追加 /// </summary> /// <param name="t05ttrn">T05_TTRN_Member</param> public void Insert(T05_TTRN_Member t05ttrn) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { context.Connection.Open(); T05_TTRN t05 = new T05_TTRN(); t05.乗務員KEY = t05ttrn.乗務員ID; t05.配車日付 = t05ttrn.配車日付; t05.登録日時 = t05ttrn.登録日時; t05.更新日時 = t05ttrn.更新日時; t05.明細区分 = t05ttrn.明細区分; t05.車輌ID = t05ttrn.車輌ID; t05.車輌番号 = t05ttrn.車輌番号; t05.行先 = t05ttrn.行先; t05.指示項目 = t05ttrn.指示項目; t05.自社部門ID = t05ttrn.自社部門ID; try { // newのエンティティに対してはAcceptChangesで新規追加となる context.T05_TTRN.ApplyChanges(t05); context.SaveChanges(); } catch (UpdateException ex) { // PKey違反等 Console.WriteLine(ex); } } }
/// <summary> /// T05_TTRNの更新 /// </summary> /// <param name="t05ttrn">T05_TTRN_Member</param> public void Update(T05_TTRN_Member t05ttrn) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { context.Connection.Open(); //更新行を特定 var ret = from x in context.T05_TTRN where x.乗務員KEY == t05ttrn.乗務員ID && x.配車日付 == t05ttrn.配車日付 orderby x.乗務員KEY, x.配車日付 select x; var t05 = ret.FirstOrDefault(); t05.更新日時 = DateTime.Now; t05.乗務員KEY = t05ttrn.乗務員ID; t05.配車日付 = t05ttrn.配車日付; t05.登録日時 = t05ttrn.登録日時; t05.明細区分 = t05ttrn.明細区分; t05.車輌ID = t05ttrn.車輌ID; t05.車輌番号 = t05ttrn.車輌番号; t05.行先 = t05ttrn.行先; t05.指示項目 = t05ttrn.指示項目; t05.自社部門ID = t05ttrn.自社部門ID; t05.AcceptChanges(); context.SaveChanges(); } }
/// <summary> /// T05_TTRNの物理削除 /// </summary> /// <param name="t05ttrn">T05_TTRN_Member</param> public void Delete(T05_TTRN_Member t05ttrn) { using (TRAC3Entities context = new TRAC3Entities(CommonData.TRAC3_GetConnectionString())) { context.Connection.Open(); //削除行を特定 var ret = from x in context.T05_TTRN where x.乗務員KEY == t05ttrn.乗務員ID && x.配車日付 == t05ttrn.配車日付 orderby x.乗務員KEY, x.配車日付 select x; var t05 = ret.FirstOrDefault(); context.DeleteObject(t05); context.SaveChanges(); } }