protected void btnNext_Click(object sender, EventArgs e) { TheCancerProject.Core.Patient thePatient = SessionObjects.ThePatient; TheCancerProject.Core.Patient thePatientToVerify = SessionObjects.ThePatient; PreliminaryExamination entityToReplace = new PreliminaryExamination(); //HINT:Manually Create try { bool doNotSaveInDB = false; if (System.Configuration.ConfigurationManager.AppSettings["DoNotSaveInDB"] != null && Boolean.TryParse(System.Configuration.ConfigurationManager.AppSettings["DoNotSaveInDB"], out doNotSaveInDB)) { if (doNotSaveInDB) { Response.Redirect("~/ThePages/Create/GeneralExamination.aspx", false); } } //if (string.IsNullOrWhiteSpace(dateMenarche.Value)) //{ // if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message")) // { // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Please Enter a valid Menarche Date" + "', function(){location = '/ThePages/Create/Biodata.aspx';});</script>", false); // } //} string pastMedicalHistory = WebObjects.selectedListBoxValues(ddlPastMedHistory); //TheCancerProject.Core.PreliminaryExamination thePreliminaryExamInSession = (thePatient != null) ? thePatient.ThePreliminaryExamination : null; TheCancerProject.Core.PreliminaryExamination thePreliminaryExam = new Core.PreliminaryExamination(); //theBiodata = theBiodataList.First(); thePreliminaryExam.AllergicReactions = (string.IsNullOrWhiteSpace(txtAllergicReactions.Value)) ? txtAllergicReactions.Value : txtAllergicReactions.Value.Trim(); thePreliminaryExam.DurationOfMenses = (string.IsNullOrWhiteSpace(txtDurationOfMenses.Value)) ? txtDurationOfMenses.Value : txtDurationOfMenses.Value.Trim(); thePreliminaryExam.LengthOfMestrualCycle = (string.IsNullOrWhiteSpace(txtLengthOfMenstrualCycle.Value)) ? txtLengthOfMenstrualCycle.Value : txtLengthOfMenstrualCycle.Value.Trim(); thePreliminaryExam.Parity = (string.IsNullOrWhiteSpace(txtParity.Value)) ? txtParity.Value : txtParity.Value.Trim(); thePreliminaryExam.PastSurgicalHistory = (string.IsNullOrWhiteSpace(txtPastSurgicalHistory.Value)) ? txtPastSurgicalHistory.Value : txtPastSurgicalHistory.Value.Trim(); thePreliminaryExam.RoutineMedications = (string.IsNullOrWhiteSpace(txtRoutineMedications.Value)) ? txtRoutineMedications.Value : txtRoutineMedications.Value.Trim(); thePreliminaryExam.Menarche = (string.IsNullOrWhiteSpace(txtMenarche.Value)) ? txtMenarche.Value : txtMenarche.Value.Trim(); thePreliminaryExam.MedicalHistory = pastMedicalHistory; //thePreliminaryExam.Menarche = Convert.ToDateTime(dateMenarche.Value); thePreliminaryExam.DateCreated = DateTime.Now; thePreliminaryExam.DateUpdated = DateTime.Now; thePreliminaryExam.UniqueID = SessionObjects.PatientUniqueID; //HINT:Manually Create Patient thePatientToSave = new Patient { TheBiodata = (thePatient != null) ? thePatient.TheBiodata : null, TheHospital = (thePatient != null) ? thePatient.TheHospital : null, TheBreastAndAxillaryExamination = (thePatient != null) ? thePatient.TheBreastAndAxillaryExamination : null, TheComplaints = (thePatient != null) ? thePatient.TheComplaints : null, TheEventsOnAdmission = (thePatient != null) ? thePatient.TheEventsOnAdmission : null, TheGeneralExamination = (thePatient != null) ? thePatient.TheGeneralExamination : null, ThePreliminaryExamination = thePreliminaryExam, LastUserAdministeringTreatment = (thePatient != null) ? thePatient.LastUserAdministeringTreatment : null, TheClinicVisits = (thePatient != null) ? thePatient.TheClinicVisits : null, TheInvestigation = (thePatient != null) ? thePatient.TheInvestigation : null, TheProcedures = (thePatient != null) ? thePatient.TheProcedures : null, TheDiagnoses = (thePatient != null) ? thePatient.TheDiagnoses : null, DateCreated = DateTime.Now, DateUpdated = DateTime.Now }; if (thePatient != null) //HINT:Manually Create { thePatient.ThePreliminaryExamination = thePreliminaryExam; } else { thePatient = thePatientToSave; } if (thePatientToVerify == null) { PreliminaryExamDAO.Save(thePreliminaryExam); PatientDAO.Save(thePatient); thePatient = new PatientDAO().RetrieveByUniqueID(SessionObjects.PatientUniqueID); //HINT:Manually Create SessionObjects.ThePatient = thePatient; //HINT:Manually Create Response.Redirect("~/ThePages/Create/GeneralExamination.aspx", false); } else if (thePatientToVerify != null && thePatientToVerify.Id > 0 && thePatientToVerify.ThePreliminaryExamination != null && thePatientToVerify.ThePreliminaryExamination.Id <= 0) { PreliminaryExamDAO.Save(thePreliminaryExam); entityToReplace = new PreliminaryExamDAO().RetrieveByUniqueID(SessionObjects.PatientUniqueID); //HINT:Manually Create thePatient.ThePreliminaryExamination = entityToReplace; //HINT:Manually Create PatientDAO.Update(thePatient); thePatient = new PatientDAO().RetrieveByUniqueID(SessionObjects.PatientUniqueID); //HINT:Manually Create SessionObjects.ThePatient = thePatient; //HINT:Manually Create Response.Redirect("~/ThePages/Create/GeneralExamination.aspx", false); } else if (thePatientToVerify != null && thePatientToVerify.Id > 0 && thePatientToVerify.ThePreliminaryExamination != null && thePatientToVerify.ThePreliminaryExamination.Id > 0 && thePatientToVerify.ThePreliminaryExamination != thePreliminaryExam) //HINT:Manually Create { thePreliminaryExam.Id = thePatient.ThePreliminaryExamination.Id; //HINT:Manually Create PreliminaryExamDAO.Update(thePreliminaryExam); entityToReplace = new PreliminaryExamDAO().RetrieveByUniqueID(SessionObjects.PatientUniqueID); //HINT:Manually Create thePatient.ThePreliminaryExamination = entityToReplace; //HINT:Manually Create PatientDAO.Update(thePatient); thePatient = new PatientDAO().RetrieveByUniqueID(SessionObjects.PatientUniqueID); //HINT:Manually Create SessionObjects.ThePatient = thePatient; //HINT:Manually Create Response.Redirect("~/ThePages/Create/GeneralExamination.aspx", false); } else if (thePatientToVerify.ThePreliminaryExamination != null && thePatientToVerify.ThePreliminaryExamination == thePreliminaryExam) { //If it's the same data, don't save or update, just redirect Response.Redirect("~/ThePages/Create/GeneralExamination.aspx", false); } else { if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message")) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Unknown error encountered. Kindly contact admin!!!" + "', function(){location = '/Start/Login.aspx';});</script>", false); } } } catch (Exception ex) { string errorMessage = ex.InnerException == null ? ex.Message : ex.InnerException.Message; if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message")) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", @"<script type='text/javascript'>alertify.alert('Message', """ + errorMessage.Replace("\n", "").Replace("\r", "") + @""", function(){});</script>", false); } } }
protected void btnNext_Click(object sender, EventArgs e) { TheCancerProject.Core.Patient thePatient = SessionObjects.ThePatient; TheCancerProject.Core.Patient thePatientToVerify = SessionObjects.ThePatient; try { bool doNotSaveInDB = false; if (System.Configuration.ConfigurationManager.AppSettings["DoNotSaveInDB"] != null && Boolean.TryParse(System.Configuration.ConfigurationManager.AppSettings["DoNotSaveInDB"], out doNotSaveInDB)) { if (doNotSaveInDB) { Response.Redirect("~/ThePages/Create/GeneralExamination.aspx", false); } } string pastMedicalHistory = WebObjects.selectedListBoxValues(ddlPastMedHistory); //TheCancerProject.Core.PreliminaryExamination thePreliminaryExamInSession = (thePatient != null) ? thePatient.ThePreliminaryExamination : null; TheCancerProject.Core.PreliminaryExamination thePreliminaryExam = new Core.PreliminaryExamination(); //theBiodata = theBiodataList.First(); thePreliminaryExam.AllergicReactions = (string.IsNullOrWhiteSpace(txtAllergicReactions.Value)) ? txtAllergicReactions.Value : txtAllergicReactions.Value.Trim(); thePreliminaryExam.DurationOfMenses = (string.IsNullOrWhiteSpace(txtDurationOfMenses.Value)) ? txtDurationOfMenses.Value : txtDurationOfMenses.Value.Trim(); thePreliminaryExam.LengthOfMestrualCycle = (string.IsNullOrWhiteSpace(txtLengthOfMenstrualCycle.Value)) ? txtLengthOfMenstrualCycle.Value : txtLengthOfMenstrualCycle.Value.Trim(); thePreliminaryExam.Parity = (string.IsNullOrWhiteSpace(txtParity.Value)) ? txtParity.Value : txtParity.Value.Trim(); thePreliminaryExam.PastSurgicalHistory = (string.IsNullOrWhiteSpace(txtPastSurgicalHistory.Value)) ? txtPastSurgicalHistory.Value : txtPastSurgicalHistory.Value.Trim(); thePreliminaryExam.RoutineMedications = (string.IsNullOrWhiteSpace(txtRoutineMedications.Value)) ? txtRoutineMedications.Value : txtRoutineMedications.Value.Trim(); thePreliminaryExam.MedicalHistory = pastMedicalHistory; thePreliminaryExam.DateCreated = DateTime.Now; thePreliminaryExam.DateUpdated = DateTime.Now; Patient thePatientToSave = new Patient { TheBiodata = (thePatient != null) ? thePatient.TheBiodata : null, TheHospital = (thePatient != null) ? thePatient.TheHospital : null, TheBreastAndAxillaryExamination = (thePatient != null) ? thePatient.TheBreastAndAxillaryExamination : null, TheComplaints = (thePatient != null) ? thePatient.TheComplaints : null, TheEventsOnAdmission = (thePatient != null) ? thePatient.TheEventsOnAdmission : null, TheGeneralExamination = (thePatient != null) ? thePatient.TheGeneralExamination : null, ThePreliminaryExamination = (thePatient != null) ? thePatient.ThePreliminaryExamination : null, LastUserAdministeringTreatment = (thePatient != null) ? thePatient.LastUserAdministeringTreatment : null, DateCreated = DateTime.Now, DateUpdated = DateTime.Now }; //thePatient.TheBiodata = theBiodata; //thePatient.TheComplaints = theComplaint; thePatient = thePatientToSave; SessionObjects.ThePatient = thePatient; if (thePatientToVerify.ThePreliminaryExamination == null) { PreliminaryExamDAO.Save(thePreliminaryExam); PatientDAO.Save(thePatientToSave); Response.Redirect("~/ThePages/Create/HistoryAndPreliminaryExamination.aspx", false); } else if (thePatientToVerify.ThePreliminaryExamination != null && thePatientToVerify.ThePreliminaryExamination != thePreliminaryExam) { PreliminaryExamDAO.Save(thePreliminaryExam); PatientDAO.Update(thePatientToSave); Response.Redirect("~/ThePages/Create/HistoryAndPreliminaryExamination.aspx", false); } else if (thePatientToVerify.ThePreliminaryExamination != null && thePatientToVerify.ThePreliminaryExamination == thePreliminaryExam) { //If it's the same data, don't save or update, just redirect Response.Redirect("~/ThePages/Create/HistoryAndPreliminaryExamination.aspx", false); } //else if (theBiodataList != null && theBiodataList.Count > 1) //{ // if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message")) // { // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Multiple Biodata Exists for this patient. Kindly contact admin!!!" + "', function(){location = '/Start/Login.aspx';});</script>", false); // } //} else { if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message")) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Unknown error encountered. Kindly contact admin!!!" + "', function(){location = '/Start/Login.aspx';});</script>", false); } } //if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message")) //{ // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", "<script type='text/javascript'>alertify.alert('Message', '" + "Admin Saved Successfully" + "', function(){location = '/Start/Login.aspx';});</script>", false); //} } catch (Exception ex) { string errorMessage = ex.InnerException == null ? ex.Message : ex.InnerException.Message; if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "message")) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "message", @"<script type='text/javascript'>alertify.alert('Message', """ + errorMessage.Replace("\n", "").Replace("\r", "") + @""", function(){});</script>", false); } } }