/// <summary>
 /// Fires when btnSubmit is clicked. Updates Instructor schedule and sends email 
 /// needed
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">Event Arguments</param>
 /// <remarks>
 /// Pseudocode follows below.
 /// <code>
 /// Begin
 ///    For each time slot.
 ///       If time slot has changed.
 ///          If time slot was a student appointment
 ///             Send  cancellation email
 ///             Remove appointment
 ///          End If
 ///       End If
 ///    End For
 ///    Update Time Data Table
 /// End
 /// </code>
 /// </remarks>
 protected void btnSubmit_Click(object sender, System.EventArgs e)
 {
     try
     {
         PersistAppointmentRequest papptRequest = new PersistAppointmentRequest();
         papptRequest.SecurityToken = "ABC123";
         papptRequest.PersistAction = PersistType.Update;
         apptTransfer.AM0800 = cmb8.SelectedValue.ToString();
         apptTransfer.AM0830 = cmb830.SelectedValue.ToString();
         apptTransfer.AM0900 = cmb9.SelectedValue.ToString();
         apptTransfer.AM0930 = cmb930.SelectedValue.ToString();
         apptTransfer.AM1000 = cmb10.SelectedValue.ToString();
         apptTransfer.AM1030 = cmb1030.SelectedValue.ToString();
         apptTransfer.AM1100 = cmb11.SelectedValue.ToString();
         apptTransfer.AM1130 = cmb1130.SelectedValue.ToString();
         apptTransfer.PM1200 = cmb12.SelectedValue.ToString();
         apptTransfer.PM1230 = cmb1230.SelectedValue.ToString();
         apptTransfer.PM0100 = cmb13.SelectedValue.ToString();
         apptTransfer.PM0130 = cmb1330.SelectedValue.ToString();
         apptTransfer.PM0200 = cmb14.SelectedValue.ToString();
         apptTransfer.PM0230 = cmb1430.SelectedValue.ToString();
         apptTransfer.PM0300 = cmb15.SelectedValue.ToString();
         apptTransfer.PM0330 = cmb1530.SelectedValue.ToString();
         apptTransfer.PM0400 = cmb16.SelectedValue.ToString();
         apptTransfer.PM0430 = cmb1630.SelectedValue.ToString();
         apptTransfer.PM0500 = cmb17.SelectedValue.ToString();
         apptTransfer.dayID = Convert.ToInt32(((DataTable)Session["day"]).Rows[0][0]);
         papptRequest.Appt = apptTransfer;
         PersistAppointmentResponse aResponse = proxy.PersistAppt(papptRequest);
         lblMessage.Text = "Your changes have been successfully saved!";
     }
     catch (Exception ex)
     {
         lblMessage.Text = ex.ToString();
     }
 }
예제 #2
0
    public PersistAppointmentResponse PersistAppt(PersistAppointmentRequest request)
    {
        PersistAppointmentResponse response = new PersistAppointmentResponse();

        // Set correlation Id

        response.CorrelationId = request.RequestId;

        try
        {
            // Call persistence request via Customer Facade.
            AppointmentFacade facade = new AppointmentFacade();

            switch (request.PersistAction)
            {
                case PersistType.Insert:
                    {
                        facade.AddStudentAppointment(request.patientID, request.DoctorID, request.Date, request.strSet, request.TimeID);

                        response.Acknowledge = AcknowledgeType.Success;
                        //facade.AddDoctor(doctor);

                        //response.Doctor = request.Doctor;
                        //response.Doctor.docID = doctor.DoctorID;

                        break;
                    }
                case PersistType.Update:
                    {
                        Appointment appt = new Appointment();

                        appt.DoctorID = request.Appt.doctorID;
                        appt.AM8 = request.Appt.AM0800;
                        appt.AM830 = request.Appt.AM0830;
                        appt.AM9 = request.Appt.AM0900;
                        appt.AM930 = request.Appt.AM0930;
                        appt.AM10 = request.Appt.AM1000;
                        appt.AM1030 = request.Appt.AM1030;
                        appt.AM11 = request.Appt.AM1100;
                        appt.AM1130 = request.Appt.AM1130;
                        appt.PM12 = request.Appt.PM1200;
                        appt.PM1230 = request.Appt.PM1230;
                        appt.PM0100 = request.Appt.PM0100;
                        appt.PM0130 = request.Appt.PM0130;
                        appt.PM0200 = request.Appt.PM0200;
                        appt.PM0230 = request.Appt.PM0230;
                        appt.PM0300 = request.Appt.PM0300;
                        appt.PM0330 = request.Appt.PM0330;
                        appt.PM0400 = request.Appt.PM0400;
                        appt.PM0430 = request.Appt.PM0430;
                        appt.PM0500 = request.Appt.PM0500;
                        int dayID=request.Appt.dayID;

                        facade.UpdateDoctorAppointment(appt,dayID);

                       // response.Customer = request.Customer;
                        break;
                    }
                //case PersistType.Delete:
                //    {
                //        int customerId = DecryptId(request.Customer.CustomerId);
                //        int rowsAffected = facade.DeleteCustomer(customerId);
                //        if (rowsAffected == 0)
                //            throw new Exception("Customer has orders and therefore cannot be deleted. ");

                //        break;
                //    }
            }

        }
        catch (Exception ex)
        {
            response.Acknowledge = AcknowledgeType.Failure;
            response.Message = ex.Message;
        }

        return response;
    }
    protected void btnSubmit_Click(object sender, System.EventArgs e)
    {
        string[] strSet = new string[2];
        Session["PATID"] = Session["PatientID"];

        for (int x = 0; x < 19; ++x)
        {
            int Time = -1;
            switch (x)
            {
                case 0:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "AM_0800", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 1:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "AM_0830", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 2:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "AM_0900", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 3:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "AM_0930", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 4:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "AM_1000", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 5:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "AM_1030", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 6:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "AM_1100", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 7:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "AM_1130", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 8:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "PM_1200", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 9:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "PM_1230", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 10:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "PM_0100", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 11:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "PM_0130", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 12:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "PM_0200", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 13:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "PM_0230", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 14:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "PM_0300", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 15:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "PM_0330", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 16:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "PM_0400", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 17:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "PM_0430", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
                case 18:
                    if (radArray[x].Checked)
                    {
                        strSet = new string[2] { "PM_0500", "'PAT" + Session["PATID"].ToString() + "'" };
                        Time = x;
                    }
                    break;
            }

            if (Time != -1)
            {
                proxy = new WebRef.Service();

                // Proxy must accept and hold cookies
                //   proxy.CookieContainer = new System.Net.CookieContainer();
                proxy.Url = new Uri(proxy.Url).AbsoluteUri;
                PersistAppointmentRequest aRequest = new PersistAppointmentRequest();
                aRequest.PersistAction = PersistType.Insert;
                aRequest.Date = Convert.ToDateTime(txtDate.Text);
                aRequest.DoctorID = Convert.ToInt32(lstInstructors.SelectedValue);
                aRequest.patientID = Convert.ToInt32(Session["PATID"]);
                aRequest.strSet = strSet;
                aRequest.TimeID = Time;
                PersistAppointmentResponse aResponse = proxy.PersistAppt(aRequest);
                if (aResponse.Acknowledge == AcknowledgeType.Success)
                    Response.Write("Success");
            }
        }
    }