/// <summary> /// Insert Ticket /// </summary> /// <param name="tk"></param> /// <returns></returns> public static bool Insert(Ticket tk) { try { QLNXeEntities entities = new QLNXeEntities(); entities.Tickets.Add(tk); entities.SaveChanges(); return true; } catch (Exception) { return false; } }
public ActionResult Edit(Ticket tk, FormCollection collection) { tk.CustomerId = CustomerBusiness.SelectIdbyName(collection["SearchCustomer"]); IFormatProvider iFP = new System.Globalization.CultureInfo("vi-VN", true); tk.StartTime = DateTime.Parse(collection["StartTime"], iFP); tk.EndTime = DateTime.Parse(collection["EndTime"], iFP); tk.MotorbikePlate = collection["SearchPlate"]; tk.TypeId = Int64.Parse(collection["ticketType"]); tk.CustomerId = CustomerBusiness.SelectIdbyName(collection["Customer.FullName"]); TicketBusiness.Update(tk); ViewBag.ticketType = new SelectList(TicketTypeBusiness.ListTicketTypes(), "Id", "Description", tk.TypeId); return PartialView("Edit", tk); }
public ActionResult Create(Ticket tk, FormCollection collection) { tk.CustomerId = CustomerBusiness.SelectIdbyName(collection["SearchCustomer"]); IFormatProvider iFP = new System.Globalization.CultureInfo("vi-VN", true); tk.StartTime = DateTime.Parse(collection["StartTime"], iFP); tk.EndTime = DateTime.Parse(collection["EndTime"], iFP); tk.Price = 0; tk.MotorbikePlate = collection["SearchPlate"]; tk.TypeId = Int64.Parse(collection["ticketType"]); TicketBusiness.Insert(tk); IEnumerable<SelectListItem> sList = new SelectList(TicketTypeBusiness.ListTicketTypes(), "Id", "Description"); ViewBag.TicketType = sList; return PartialView("Create"); }
/// <summary> /// Update Ticket /// </summary> /// <param name="tk"></param> /// <returns></returns> public static bool Update(Ticket tk) { try { QLNXeEntities entities = new QLNXeEntities(); var ticket = entities.Tickets.Find(tk.TicketId); entities.Entry(ticket).CurrentValues.SetValues(tk); entities.SaveChanges(); return true; } catch (Exception) { return false; } }