public TRANSPORT_COST GetById2(int input) { TRANSPORT_COST transport_costs = context.Transport_Costs.Find(input); var temp = from tc in context.Transport_Costs.ToList() join t in context.Travels.ToList() on tc.travel_id equals t.travel_id join ty in context.Tipes.ToList() on tc.type_id equals ty.type_id where tc.transport_id == input select tc; if (transport_costs == null) { Console.Write("Id " + input + " Tidak Ada"); } else { Console.WriteLine("\nID Travel : " + transport_costs.travel_id); Console.WriteLine("ID Type : " + transport_costs.type_id); Console.WriteLine("-------------------------"); Console.WriteLine("Id : " + transport_costs.transport_id); Console.WriteLine("Cost Transport : " + transport_costs.cost); Console.WriteLine("Attachment : " + transport_costs.attachment); Console.WriteLine("Date : " + transport_costs.date); Console.WriteLine("-------------------------"); } return(transport_costs); }
public int Delete(int input) { TRANSPORT_COST tRANSPORT_COST = context.Transport_Costs.Find(input); context.Entry(tRANSPORT_COST).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); Console.Write("Transport Cost dengan ID " + input + " Berhasil terhapus!"); return(input); }
public int Update(int input) { string attachment; DateTime date; int harga, types; // inputan by user var temp = from tc in context.Transport_Costs.ToList() join t in context.Travels.ToList() on tc.travel_id equals t.travel_id join ty in context.Tipes.ToList() on tc.type_id equals ty.type_id select tc; TRANSPORT_COST transport_costs = context.Transport_Costs.Find(input); Console.WriteLine("------------Data sebelum di Update-------------"); Console.WriteLine("\nID Travel : " + transport_costs.travel_id); Console.WriteLine("ID Type : " + transport_costs.type_id); Console.WriteLine("\n-------------------------"); Console.WriteLine("Id : " + transport_costs.transport_id); Console.WriteLine("Cost Transport : " + transport_costs.cost); Console.WriteLine("Attachment : " + transport_costs.attachment); Console.WriteLine("Date : " + transport_costs.date); Console.WriteLine("-------------------------"); Console.Write("\nMasukkan Cost Transport : "); harga = Convert.ToInt32(Console.ReadLine()); Console.Write("Attachment : "); attachment = Console.ReadLine(); Console.Write("Masukkan Date : "); date = Convert.ToDateTime(Console.ReadLine()); Console.Write("Masukkan ID Type : "); types = Convert.ToInt32(Console.ReadLine()); TRANSPORT_COST tRANSPORT_COST = context.Transport_Costs.Find(input); tRANSPORT_COST.cost = harga; tRANSPORT_COST.attachment = attachment; tRANSPORT_COST.date = date; tRANSPORT_COST.type_id = types; context.Entry(tRANSPORT_COST).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); Console.WriteLine("\n------------Data sesudah di Update-------------"); Console.WriteLine("\nID Travel : " + tRANSPORT_COST.travel_id); Console.WriteLine("ID Type : " + tRANSPORT_COST.type_id); Console.WriteLine("\n-------------------------"); Console.WriteLine("Id : " + tRANSPORT_COST.transport_id); Console.WriteLine("Cost Transport : " + tRANSPORT_COST.cost); Console.WriteLine("Attachment : " + tRANSPORT_COST.attachment); Console.WriteLine("Date : " + tRANSPORT_COST.date); Console.WriteLine("-------------------------"); return(input); }
public TRANSPORT_COST GetById(int input) { TRANSPORT_COST transport_costs = context.Transport_Costs.Find(input); if (transport_costs == null) { Console.Write("Id " + input + " Tidak Ada"); } return(transport_costs); }
public void Insert() { string attachment; DateTime date; int harga, travel, types; // inputan by user Console.Write("Masukkan ID Travel : "); travel = Convert.ToInt32(Console.ReadLine()); Console.Write("Masukkan ID Type : "); types = Convert.ToInt32(Console.ReadLine()); Console.Write("Masukkan Cost Transport : "); harga = Convert.ToInt32(Console.ReadLine()); Console.Write("Attachment : "); attachment = Console.ReadLine(); Console.Write("Masukkan Date : "); date = Convert.ToDateTime(Console.ReadLine()); TRANSPORT_COST transport_costs = new TRANSPORT_COST() { cost = harga, attachment = attachment, date = date, travel_id = travel, type_id = types }; try { context.Transport_Costs.Add(transport_costs); context.SaveChanges(); } catch (Exception ex) { Console.Write(ex.InnerException); Console.Write(ex.Message); Console.Write(ex.StackTrace); } }