protected void btnSubmit_Click(object sender, EventArgs e) { string meetingName = txtMeetingName.Text; int numberofParticipants = Convert.ToInt32(txtNumberofParticipants.Text); DateTime start = DateTime.Parse(txtStartDate.Text + " " + txtStartTime.Text); DateTime end = DateTime.Parse(txtEndDate.Text + " " + txtEndTime.Text); int roomID = Convert.ToInt32(ddlRooms.SelectedValue); string description = txtDescription.Text; string script; if (start >= end) // 检查结束时间是否大于起始时间 { script = "<script type='text/javascript'>alert('会议结束时间必须大于起始时间');</script>"; Page.ClientScript.RegisterStartupScript(this.GetType(), "dateerror", script); return; } Meeting meeting = new Meeting(); meeting.MeetingName = meetingName; meeting.NumberofParticipants = numberofParticipants; meeting.StartTime = start; meeting.EndTime = end; meeting.Description = description; meeting.Room = BLLRoom.GetRoomByID(roomID); meeting.Reservationist = BLLStaff.GetEmployeeforLoggedInUser(); meeting.Status = MeetingStatus.Normal; meeting.Participants = new List <Employee>(); foreach (ListItem item in lbSelectedEmployees.Items) { int employeeID = Convert.ToInt32(item.Value); meeting.Participants.Add(new Employee { EmployeeID = employeeID }); } MeetingOpResults result = BLLMeeting.ReserveMeeting(meeting); script = string.Format("<script>alert('会议预订成功!');window.location.href='MyReservations.aspx';</script>"); switch (result) { case MeetingOpResults.NotEnoughCapacity: script = string.Format("<script>alert('所选会议室容量为{0},无法容纳{1}人');</script>", meeting.Room.Capacity, meeting.NumberofParticipants); break; case MeetingOpResults.ReservationTooLate: script = string.Format("<script>alert('距会议开始时间{0}已不足30分钟,请推迟时间');</script>", meeting.StartTime.ToString("HH:mm")); break; case MeetingOpResults.RoomScheduleNotAvailable: script = string.Format("<script>alert('该会议室已被预订,请更改时间或重新选择会议室');</script>"); break; } Page.ClientScript.RegisterStartupScript(this.GetType(), "result", script); }
protected void btnSubmit_Click(object sender, EventArgs e) { int meetingID = Convert.ToInt32(Request["meetingid"]); string reason = txtDescription.Text; MeetingOpResults result = BLLMeeting.CancelMeeting(meetingID, reason); string script = ""; if (result == MeetingOpResults.MeetingCanNotCancel) { script = "<script>alert('会议已经结束或正在进行中,不能撤销!');</script>"; } else { script = "<script>alert('会议撤销成功!');window.location.href='MyReservations.aspx';</script>"; } Page.ClientScript.RegisterStartupScript(this.GetType(), "result", script); }