private bool AppointmentExist()
    {
        int          visitid = 0;
        DataTable    theDt;
        IAppointment FormManager;
        IQCareUtils  theUtils = new IQCareUtils();
        DateTime     temp     = Convert.ToDateTime(theUtils.MakeDate(txtAppDate.Text));

        FormManager = (IAppointment)ObjectFactory.CreateInstance("BusinessProcess.Scheduler.BAppointment, BusinessProcess.Scheduler");

        //*******Check if user is editing and existing appointment then also send the visit id of the appointment*******//
        //if (Request.QueryString["PatientVisitID"] != null)
        //{
        //    visitid = Convert.ToInt32(Request.QueryString["PatientVisitID"]);
        //}

        if (Session["PatientVisitId"] != null)
        {
            visitid = Convert.ToInt32(Session["PatientVisitId"]);
        }

        //Nidhi
        //theDt = (DataTable)FormManager.CheckAppointmentExistance(Convert.ToInt32(Session["PatientId"]), Convert.ToInt32(Session["AppLocationId"]), temp, Convert.ToInt32(ddAppPurpose.SelectedValue), visitid);
        theDt = (DataTable)FormManager.CheckAppointmentExistance(Convert.ToInt32(Session["PatientId"]), Convert.ToInt32(Session["AppLocationId"]), txtAppDate.Text, Convert.ToInt32(ddAppPurpose.SelectedValue), visitid);
        if (Convert.ToInt32(theDt.Rows[0][0]) > 0)
        {
            return(true);
        }


        return(false);
    }
        private bool AppointmentExist(DateTime appDate, int ReasonId, int ModuleId, int VisitId)
        {
            DataTable    theDt;
            IAppointment FormManager;

            FormManager = (IAppointment)ObjectFactory.CreateInstance("BusinessProcess.Scheduler.BAppointment, BusinessProcess.Scheduler");

            theDt = (DataTable)FormManager.CheckAppointmentExistance(this.PatientId, this.FacilityId, appDate, ReasonId, VisitId, ModuleId);

            if (Convert.ToInt32(theDt.Rows[0][0]) > 0)
            {
                return(true);
            }

            return(false);
        }