private void deleteAppointment()
    {
        //*******Delete the patient on the basis of patient id ********//
        IAppointment FormManager;

        FormManager = (IAppointment)ObjectFactory.CreateInstance("BusinessProcess.Scheduler.BAppointment, BusinessProcess.Scheduler");
        //int theResultRow = FormManager.DeletePatientAppointmentDetails(Convert.ToInt32(Request.QueryString["PatientId"]), Convert.ToInt32(Request.QueryString["LocationID"]),Convert.ToInt32(ViewState["VisitID"]) );

        int theResultRow = FormManager.DeletePatientAppointmentDetails(Convert.ToInt32(Request.QueryString["PatientId"]), Convert.ToInt32(Session["AppLocationId"]), Convert.ToInt32(ViewState["VisitID"]));

        //  int theResultRow = FormManager.DeletePatientAppointmentDetails(Convert.ToInt32(Session["PatientId"]), Convert.ToInt32(Session["AppLocationId"]), Convert.ToInt32(ViewState["VisitID"]));

        if (theResultRow == 0)
        {
            IQCareMsgBox.Show("DeletePatientError", this);
            return;
        }
        else
        {
            string theUrl;
            //theUrl = string.Format("{0}&FormName={1}&PatientId={2}&LocationId={3}", "./frmScheduler_AppointmentNew.aspx?name=Edit","EditDelete", Request.QueryString["PatientId"], Session["AppLocationId"].ToString());
            theUrl = string.Format("{0}&FormName={1}&PatientId={2}&LocationId={3}", "./frmScheduler_AppointmentNew.aspx?name=Edit", "EditDelete", Session["PatientId"], Session["AppLocationId"].ToString());

            //  theUrl = string.Format("{0}&FormName={1}&AppointmentStatus={2}", "./frmScheduler_AppointmentMain.aspx?name=Add", "AppointmentMain", "All");

            if (Request.QueryString["FormName"] == "Appointment History")
            {
                //theUrl = string.Format("{0}&PatientId={1}&LocationId={2}&FormName={3}", "../Scheduler/frmScheduler_AppointmentHistory.aspx?name=Add", Convert.ToInt32(Request.QueryString["PatientId"]), Session["AppLocationId"].ToString(), "PatientHome");
                theUrl = string.Format("{0}&PatientId={1}&LocationId={2}&FormName={3}", "../Scheduler/frmScheduler_AppointmentHistory.aspx?name=Add", Convert.ToInt32(Session["PatientId"]), Session["AppLocationId"].ToString(), "PatientHome");
            }

            Response.Redirect(theUrl);
        }
    }
    private void deleteAppointment()
    {
        //*******Delete the patient on the basis of patient id ********//
        IAppointment FormManager;

        FormManager = (IAppointment)ObjectFactory.CreateInstance("BusinessProcess.Scheduler.BAppointment, BusinessProcess.Scheduler");
        //int theResultRow = FormManager.DeletePatientAppointmentDetails(Convert.ToInt32(Request.QueryString["PatientId"]), Convert.ToInt32(Request.QueryString["LocationID"]), Convert.ToInt32(Request.QueryString["PatientVisitID"]));
        int theResultRow = FormManager.DeletePatientAppointmentDetails(Convert.ToInt32(Session["PatientId"]), Convert.ToInt32(Session["AppLocationId"]), Convert.ToInt32(Session["PatientVisitId"]));

        if (theResultRow == 0)
        {
            IQCareMsgBox.Show("DeletePatientError", this);
            return;
        }
        else
        {
            string theUrl;
            theUrl = string.Format("{0}", "./frmScheduler_AppointmentMain.aspx");
            if (Request.QueryString["FormName"] == "Appointment History")
            {
                theUrl = string.Format("{0}?FormName={1}", "../Scheduler/frmScheduler_AppointmentHistory.aspx?name=Add", "PatientHome");
            }
            Response.Redirect(theUrl);
            //Server.Transfer(theUrl);
        }
    }