Пример #1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        IAppointment FormManager;
        int          theResultRow = 0;
        DateTime     currentDate;
        Boolean      editData = false;
        DateTime     enteredDate;

        try
        {
            //*******First check whether the appointment date, purpose and provider is being selected*******//
            IQCareUtils theUtil = new IQCareUtils();
            if (checkEntriesShowMessages())
            {
                //*******Save all the details and create a new appointment*******//
                if (checkDate())
                {
                    if (AppointmentExist())
                    {
                        IQCareMsgBox.Show("AppointmentExist", this);
                        return;
                    }
                    else
                    {
                        //First check that appdate must be with in a year not greter then that
                        currentDate = getCurrentDate();
                        //enteredDate = Convert.ToDateTime(txtAppDate.Text);


                        enteredDate = Convert.ToDateTime(theUtil.MakeDate(txtAppDate.Text));

                        if (currentDate.AddYears(1) < enteredDate)
                        {
                            IQCareMsgBox.Show("AppointmentWithInAYear", this);
                            return;
                        }
                        if (Request.QueryString["FormName"] != null)
                        {
                            if ((Request.QueryString["FormName"] == "EditDelete") || (Request.QueryString["FormName"] == "Appointment History"))
                            {
                                //*******if redirected from appointment edit/delete then update the data*******//
                                FormManager = (IAppointment)ObjectFactory.CreateInstance("BusinessProcess.Scheduler.BAppointment, BusinessProcess.Scheduler");

                                //theResultRow = FormManager.UpdatePatientppointmentDetails(Convert.ToInt32(patientId), Convert.ToInt32(Request.QueryString["LocationID"]), Convert.ToInt32(Request.QueryString["PatientVisitID"]), Convert.ToDateTime(txtAppDate.Text), Convert.ToInt32(ddAppPurpose.SelectedValue),Convert.ToInt32(Session["AppUserId"]), Convert.ToInt32(ddAppProvider.SelectedValue), currentDate);
                                //update by-nidhi
                                //Desc- changing datetime to string
                                //theResultRow = FormManager.UpdatePatientppointmentDetails(Convert.ToInt32(patientId), Convert.ToInt32(Session["AppLocationId"]), Convert.ToInt32(Session["PatientVisitId"]), enteredDate, Convert.ToInt32(ddAppPurpose.SelectedValue), Convert.ToInt32(Session["AppUserId"]), Convert.ToInt32(ddAppProvider.SelectedValue), currentDate);
                                theResultRow = FormManager.UpdatePatientppointmentDetails(Convert.ToInt32(patientId), Convert.ToInt32(Session["AppLocationId"]), Convert.ToInt32(Session["PatientVisitId"]), txtAppDate.Text, Convert.ToInt32(ddAppPurpose.SelectedValue), Convert.ToInt32(Session["AppUserId"]), Convert.ToInt32(ddAppProvider.SelectedValue), currentDate.ToString("dd-MMM-yyyy"));
                                editData     = true;
                            }
                        }
                        if (!editData)
                        {
                            //*******if redirected from appointment main then save the data*******//
                            FormManager = (IAppointment)ObjectFactory.CreateInstance("BusinessProcess.Scheduler.BAppointment, BusinessProcess.Scheduler");
                            //theResultRow = FormManager.SaveAppointment(Convert.ToInt32(patientId), Convert.ToInt32(Session["AppLocationId"]), txtAppDate.Text, Convert.ToInt32(ddAppPurpose.SelectedValue), Convert.ToInt32(ddAppProvider.SelectedValue), Convert.ToInt32(Session["AppUserId"]),Application["AppCurrentDate"].ToString());

                            //john scheduler
                            DataSet NoOfAppointments = FormManager.CheckNoOfAppointments(Convert.ToInt32(Session["AppLocationId"]), txtAppDate.Text, Convert.ToInt32(ddAppPurpose.SelectedValue));
                            if (ddAppPurpose.SelectedValue == "110")
                            {
                                if (Convert.ToInt32(NoOfAppointments.Tables[0].Rows[0][0].ToString()) > 90)
                                {
                                    string script = "<script type=\"text/javascript\">alert('Limit for that day has been reached. Kindly select another day.');</script>";
                                    ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script);
                                }
                                else
                                {
                                    theResultRow = FormManager.SaveAppointment(Convert.ToInt32(patientId), Convert.ToInt32(Session["AppLocationId"]), txtAppDate.Text, Convert.ToInt32(ddAppPurpose.SelectedValue), Convert.ToInt32(ddAppProvider.SelectedValue), Convert.ToInt32(Session["AppUserId"]), Application["AppCurrentDate"].ToString());
                                }
                            }
                            else
                            {
                                theResultRow = FormManager.SaveAppointment(Convert.ToInt32(patientId), Convert.ToInt32(Session["AppLocationId"]), txtAppDate.Text, Convert.ToInt32(ddAppPurpose.SelectedValue), Convert.ToInt32(ddAppProvider.SelectedValue), Convert.ToInt32(Session["AppUserId"]), Application["AppCurrentDate"].ToString());
                            }
                            //here
                        }
                        if (theResultRow == 0)
                        {
                            IQCareMsgBox.Show("AppointmentCreationError", this);
                            return;
                        }
                        else
                        {
                            if (Request.QueryString["opento"] == "popup")
                            {
                                selfClose();
                            }
                            else
                            {
                                string theUrl;
                                theUrl = string.Format("{0}", "./frmScheduler_AppointmentMain.aspx?name=Add");

                                if (Request.QueryString["FormName"] != null)
                                {
                                    if (Request.QueryString["FormName"] == "PatientHome")
                                    {
                                        theUrl = string.Format("{0}", "../ClinicalForms/frmPatient_Home.aspx?name=Add");
                                    }

                                    if ((Request.QueryString["FormName"] == "Appointment History") || (Request.QueryString["FormName"] == "Appointment History New"))
                                    {
                                        //Session["PatientId"]
                                        //theUrl = string.Format("{0}&PatientId={1}&LocationId={2}&FormName={3}&sts={4}", "../Scheduler/frmScheduler_AppointmentHistory.aspx?name=Add", Convert.ToInt32(Request.QueryString["PatientId"]), Session["AppLocationId"].ToString(), "PatientHome", Request.QueryString["sts"].ToString());
                                        theUrl = string.Format("{0}&FormName={1}", "../Scheduler/frmScheduler_AppointmentHistory.aspx?name=Add", "PatientHome");
                                    }
                                }
                                Response.Redirect(theUrl);
                                //Server.Transfer(theUrl);
                            }
                        }
                    }
                }
            }
            else
            {
                return;
            }
        }
        catch (Exception err)
        {
            MsgBuilder theBuilder = new MsgBuilder();
            theBuilder.DataElements["MessageText"] = err.Message.ToString();
            IQCareMsgBox.Show("#C1", theBuilder, this);
            return;
        }
        finally
        {
            FormManager = null;
        }
    }