private void delete() { int StudentID; StudentID = int.Parse(studentID.Text); business.Delete(StudentID); }
[Test]//Passed public void TestInsertUpdateDelete() { //permit int studentID = 189431483; String model = "Mini Cooper"; String reg = "181-MO-21533"; String owner = "Kyle Green"; int parkingSpace = 19; DateTime due_date = new DateTime(2018, 07, 07); //test insert into database businessTest.Insert(studentID, model, reg, owner, parkingSpace, due_date); //change due date due_date = new DateTime(2019, 07, 07); //update this permit with new due date businessTest.Update(studentID, model, reg, owner, parkingSpace, due_date); //delete this permit businessTest.Delete(studentID); }
//Console Menu that interacts with business layer public static void Main(string[] args) { Application.Run(new PermitSystem()); //variables int studentID; String model; String reg; String owner; int parkingSpace; DateTime due_date; int option; //Menu option Console.WriteLine("Enter 1 to insert an entry, 2 to show entries, 3 to update an entry, 4 to delete an entry,\n" + " 5 to calculate percent of valid utilised Permits, 6 to Determine fees due, 7 to determine number of unique vehicle models and 0 to exit"); Console.WriteLine("Enter an option"); option = Convert.ToInt32(Console.ReadLine()); //while the entry is not 0 keep asking for an option while (option != 0) { //insert entry if (option == 1) { Console.WriteLine("Enter Student id: "); studentID = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter car model"); model = Console.ReadLine(); Console.WriteLine("Enter car registration"); reg = Console.ReadLine(); Console.WriteLine("Enter owners name"); owner = Console.ReadLine(); Console.WriteLine("Enter Parking Space number: "); parkingSpace = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Day: "); var day = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Month: "); var month = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Year: "); var year = Convert.ToInt32(Console.ReadLine()); due_date = new DateTime(year, month, day); business.Insert(studentID, model, reg, owner, parkingSpace, due_date); } //show table contents else if (option == 2) { business.ShowTable(); } //update an entry else if (option == 3) { Console.WriteLine("Enter Student ID to update: "); studentID = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter car model"); model = Console.ReadLine(); Console.WriteLine("Enter car registration"); reg = Console.ReadLine(); Console.WriteLine("Enter owners name"); owner = Console.ReadLine(); Console.WriteLine("Enter Parking Space number: "); parkingSpace = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Due Date"); Console.WriteLine("Day: "); var day = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Month: "); var month = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Year: "); var year = Convert.ToInt32(Console.ReadLine()); due_date = new DateTime(year, month, day); business.Update(studentID, model, reg, owner, parkingSpace, due_date); } //delete an entry else if (option == 4) { Console.WriteLine("Enter Student ID to delete: "); studentID = Convert.ToInt32(Console.ReadLine()); business.Delete(studentID); } //Returns the percent of valid (in date ) permits in the system currently else if (option == 5) { Console.WriteLine(business.PrintPercent()); } //Returns all permits out of date and returns fee incured depending on time due else if (option == 6) { business.CollectFees(); } //Returns unique vehicle models currently held by the system else if (option == 7) { business.UniqueVehicles(); } //subsequent request for option Console.WriteLine("Enter 1 to insert an entry, 2 to show entries, 3 to update an entry and 4 to delete an entry," + "\n 5 to calculate percent of valid utilised Permits, 6 to Determine fees due, 7 to determine number of unique vehicle models"); Console.WriteLine("Enter an option"); option = Convert.ToInt32(Console.ReadLine()); } Console.ReadLine(); }
public virtual ActionResult Delete(int id) { var result = Bll.Delete(id); return(Json(new { state = result > 0 ? true : false, msg = result > 0 ? "删除成功!" : "删除失败!" })); }