public PatientAppointment FindPatientAppointment(PatientAppointment patientAppt)
        {
            PatientAppointmentInformation patientApptRecord = null;;
            PatientAppointment            patientAppt1      = new PatientAppointment();

            var appointmentquery = from patients in patientApptDataContext.PatientAppointmentInformations where patients.ApptId == patientAppt.ApptId select patients;

            patientApptRecord = appointmentquery.First();

            patientAppt1.AppointmentDate    = patientApptRecord.ApptDate;
            patientAppt1.ApptId             = patientApptRecord.ApptId;
            patientAppt1.ImageAfterTherapy  = dataEncryptionAlgorithm.DecryptData(patientApptRecord.ImageAfterTherapy);
            patientAppt1.ImageBeforeTherapy = dataEncryptionAlgorithm.DecryptData(patientApptRecord.ImageBeforeTherapy);
            patientAppt1.OilsAndTherapy     = dataEncryptionAlgorithm.DecryptData(patientApptRecord.TherapyPerformed);
            patientAppt1.SessionGoals       = dataEncryptionAlgorithm.DecryptData(patientApptRecord.SessionGoals);

            patientAppt1.PulseKD1 = dataEncryptionAlgorithm.DecryptData(patientApptRecord.KD1);
            patientAppt1.PulseKD2 = dataEncryptionAlgorithm.DecryptData(patientApptRecord.KD2);
            patientAppt1.PulseLHT = dataEncryptionAlgorithm.DecryptData(patientApptRecord.LHT);
            patientAppt1.PulseLV  = dataEncryptionAlgorithm.DecryptData(patientApptRecord.LV);
            patientAppt1.PulseRLU = dataEncryptionAlgorithm.DecryptData(patientApptRecord.RLU);
            patientAppt1.PulseSP  = dataEncryptionAlgorithm.DecryptData(patientApptRecord.SP);

            return(patientAppt1);
        }
 public PatientAppointmentInformationTableManager()
 {
     //
     // TODO: Add constructor logic here
     //
     patientApptDataContext        = new PatientAppointmentInfomationDataContext(WebConfigurationManager.ConnectionStrings["MyTherapistDatabaseConnectionString"].ConnectionString);
     patientAppointmentInformation = new PatientAppointmentInformation();
     dataEncryptionAlgorithm       = new MyTherapistEncryption.SecurityController();
 }
        public void Update(PatientAppointment patientAppt)
        {
            PatientAppointmentInformation patientApptRecord = null;
            bool insert = false;

            try
            {
                var appointmentquery = from patients in patientApptDataContext.PatientAppointmentInformations where patients.ApptId == patientAppt.ApptId select patients;
                patientApptRecord = appointmentquery.First();

                patientApptRecord.LV  = dataEncryptionAlgorithm.EncryptData(patientAppt.PulseLV);
                patientApptRecord.RLU = dataEncryptionAlgorithm.EncryptData(patientAppt.PulseRLU);
                patientApptRecord.KD1 = dataEncryptionAlgorithm.EncryptData(patientAppt.PulseKD1);
                patientApptRecord.SP  = dataEncryptionAlgorithm.EncryptData(patientAppt.PulseSP);
                patientApptRecord.LHT = dataEncryptionAlgorithm.EncryptData(patientAppt.PulseLHT);
                patientApptRecord.KD2 = dataEncryptionAlgorithm.EncryptData(patientAppt.PulseKD2);

                patientApptRecord.ImageBeforeTherapy = dataEncryptionAlgorithm.EncryptData(patientAppt.ImageBeforeTherapy);
                patientApptRecord.ImageAfterTherapy  = dataEncryptionAlgorithm.EncryptData(patientAppt.ImageAfterTherapy);

                patientApptRecord.TherapyPerformed = dataEncryptionAlgorithm.EncryptData(patientAppt.OilsAndTherapy);
                patientApptRecord.SessionGoals     = dataEncryptionAlgorithm.EncryptData(patientAppt.SessionGoals);
            }
            catch (Exception ex)
            {
                ex.GetHashCode();
                insert = true;
            }

            if (insert)
            {
                patientApptRecord             = new PatientAppointmentInformation();
                patientApptRecord.PatientId   = patientAppt.PatientId;
                patientApptRecord.ApptId      = Guid.NewGuid();
                patientApptRecord.ApptDate    = patientAppt.AppointmentDate;
                patientApptRecord.TherapistId = patientAppt.TherapistId;

                patientApptRecord.LV  = dataEncryptionAlgorithm.EncryptData(patientAppt.PulseLV);
                patientApptRecord.RLU = dataEncryptionAlgorithm.EncryptData(patientAppt.PulseRLU);
                patientApptRecord.KD1 = dataEncryptionAlgorithm.EncryptData(patientAppt.PulseKD1);
                patientApptRecord.SP  = dataEncryptionAlgorithm.EncryptData(patientAppt.PulseSP);
                patientApptRecord.LHT = dataEncryptionAlgorithm.EncryptData(patientAppt.PulseLHT);
                patientApptRecord.KD2 = dataEncryptionAlgorithm.EncryptData(patientAppt.PulseKD2);

                patientApptRecord.ImageBeforeTherapy = dataEncryptionAlgorithm.EncryptData(patientAppt.ImageBeforeTherapy);
                patientApptRecord.ImageAfterTherapy  = dataEncryptionAlgorithm.EncryptData(patientAppt.ImageAfterTherapy);

                patientApptRecord.TherapyPerformed = dataEncryptionAlgorithm.EncryptData(patientAppt.OilsAndTherapy);
                patientApptRecord.SessionGoals     = dataEncryptionAlgorithm.EncryptData(patientAppt.SessionGoals);


                patientApptDataContext.PatientAppointmentInformations.InsertOnSubmit(patientApptRecord);
            }

            patientApptDataContext.SubmitChanges();
        }
    protected void btnDeletePatient_Click(object sender, EventArgs e)
    {
        PatientDataContext patientDC       = new PatientDataContext("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename = C:\\SoftwareDevelopmentProjects\\WebProjects\\myTherapist\\myTherapist\\App_Data\\myTherapist.mdf; Integrated Security = True");
        PatientInformation patientToDelete = new PatientInformation();

        PatientAppointmentInfomationDataContext patientAppointmentInformationDC       = new PatientAppointmentInfomationDataContext("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename = C:\\SoftwareDevelopmentProjects\\WebProjects\\myTherapist\\myTherapist\\App_Data\\myTherapist.mdf; Integrated Security = True");
        PatientAppointmentInformation           patientAppointmentInformationToDelete = new PatientAppointmentInformation();

        Int32 patientId = 0;

        if (Session[CommonDefinitions.CommonDefinitions.PATIENT_ID] != null)
        {
            if (Session[CommonDefinitions.CommonDefinitions.DELETE_PATIENT_WARNING] == null)
            {
                lblWarningText.Text      = "Click Delete again to confirm this action.";
                lblWarningText.ForeColor = System.Drawing.Color.Red;
                lblWarningText.Visible   = true;
                Session[CommonDefinitions.CommonDefinitions.DELETE_PATIENT_WARNING] = "yes";
            }
            else
            {
                if (Int32.TryParse(Session[CommonDefinitions.CommonDefinitions.PATIENT_ID].ToString(), out patientId))
                {
                    Session[CommonDefinitions.CommonDefinitions.DELETE_PATIENT_WARNING] = null;

                    PatientInformationTableManager patientTableMgr = new PatientInformationTableManager();
                    Patient patientInfo = new Patient();
                    patientInfo.Id = patientId;
                    patientTableMgr.Delete(patientInfo);


                    lblWarningText.Visible = false;

                    PatientListing1.LoadGrid();
                }
            }
        }
        else
        {
            lblWarningText.Visible   = true;
            lblWarningText.Text      = "Select a patient to delete.";
            lblWarningText.ForeColor = System.Drawing.Color.Red;
        }
    }
 partial void DeletePatientAppointmentInformation(PatientAppointmentInformation instance);
 partial void InsertPatientAppointmentInformation(PatientAppointmentInformation instance);