public int UpdateSchedule(Schedule schedule, int roomID, int hourID, string date) { return(dao.UpdateSchedule(schedule, roomID, hourID, date)); }
//update lai list protected void btnUpdate_Click(object sender, EventArgs e) { string id = txtScheduleID.Text; string date = ParseExactDateString(txtDate.Text.Trim()); string time = ConvertToTime(dlHour.SelectedValue, dlMinute.SelectedValue, dlState.SelectedValue.ToUpper()); float price = 0; try { price = float.Parse(txtPrice.Text); } catch { SetMessageTextAndColor("Price must be a number!", Color.Red); return; } if (!CheckDateTime(date, time)) { SetMessageTextAndColor("Date Format is invalid, format: MM/dd/yyyy.", Color.Red); return; } string datetime = date + " " + time; string movieid = dlMovieID.SelectedValue; int roomID = Convert.ToInt32(dlRoomID.SelectedValue); List <ScheduleDTO> list = (List <ScheduleDTO>)Session["AdminScheduleList"]; foreach (ScheduleDTO item in list) { if (movieid.Equals(item.MovieID) && roomID == item.RoomID && datetime.Equals(ConvertScheduleDateInListToCompare(item.ScheduleDate.ToString()))) { SetMessageTextAndColor("This time: " + datetime + " with Room: " + roomID + " and MovieID: " + movieid + " has already been added, please try again!", Color.Red); return; } else if (datetime.Equals(ConvertScheduleDateInListToCompare(item.ScheduleDate.ToString())) && roomID == item.RoomID) { SetMessageTextAndColor("This time: " + datetime + ", at Room: " + roomID + " has already been set up. Please try again.", Color.Red); return; } } string format = "MM/dd/yyyy hh:mm:ss tt"; ScheduleDTO dto = new ScheduleDTO { ScheduleID = id, ScheduleDate = DateTime.ParseExact(datetime, format, CultureInfo.CurrentCulture), MovieID = movieid, RoomID = roomID, PriceOfTicket = price }; if (ScheduleDaos.UpdateSchedule(dto)) { List <ScheduleDTO> ListforUpdate = (List <ScheduleDTO>)Session["AdminSearchList"]; foreach (ScheduleDTO item in ListforUpdate.ToList()) { if (item.ScheduleID.Equals(id)) { item.MovieID = movieid; item.PriceOfTicket = price; item.RoomID = roomID; item.ScheduleDate = DateTime.ParseExact(datetime, format, CultureInfo.CurrentCulture); } } gvStaffList.DataSource = ListforUpdate; gvStaffList.DataBind(); SetMessageTextAndColor("Successfully updated!", Color.Green); } else { SetMessageTextAndColor("Failed to update!", Color.Red); } }