public ActionResult Add() { DiagnosisAdd objFrm = new DiagnosisAdd(); try { var symptomTypes = diagnosisRepository.GetSymptomType(); var employeeLists = employeeRepository.Get(); var strValue = "1990-01-01"; DateTime objDate; DateTime.TryParse(strValue, out objDate); objFrm.ExpiredDate = objDate; diagnosisModel = new DiagnosisModels { diagnosisAdd = objFrm, symptomTypes = symptomTypes, EmployeeLists = employeeLists, checkPost = false, checkError = false }; } catch (Exception ex) { log.Error(ex); ModelState.AddModelError(string.Empty, Translator.UnexpectedError); } return(View(diagnosisModel)); }
private void button1_Click(object sender, EventArgs e) { if (radioButton2.Checked) { if (String.IsNullOrEmpty(textBox2.Text)) { errorProvider1.SetError(textBox2, "Введите новое лекарство!"); } else { Drug drug = new Drug(textBox2.Text, ""); Drugs.Add(drug); DrugAdd?.Invoke(this, new DrugOrDiagnosisEventArgs(drug.Medicines, drug.Description)); MessageBox.Show("Лекарство успешно добавлено", "Готово", MessageBoxButtons.OK, MessageBoxIcon.Information); radioButton1.PerformClick(); radioButton2.PerformClick(); } } if (radioButton1.Checked) { if (String.IsNullOrEmpty(textBox2.Text)) { errorProvider1.SetError(textBox2, "Введите новый диагноз!"); } else { Diagnoses diagnosis = new Diagnoses(textBox2.Text, ""); Diagnoses.Add(diagnosis); DiagnosisAdd?.Invoke(this, new DrugOrDiagnosisEventArgs(diagnosis.Diagnosis, diagnosis.Description)); MessageBox.Show("Диагноз успешно добавлен", "Готово", MessageBoxButtons.OK, MessageBoxIcon.Information); radioButton2.PerformClick(); radioButton1.PerformClick(); } } }
public ActionResult Add(DiagnosisAdd objFrm) { bool checkError = true; Diagnosis diagnosis = new Diagnosis(); if (objFrm.ExpiredDate.Year < 2001) { objFrm.ExpiredDate = DateTime.Parse("01-01-2099"); } /* start check Patient_Name is correct*/ var objectDTOPatient = patientRepository.GetDTOPatientById(objFrm.PatientId); if (objectDTOPatient != null) { if (string.IsNullOrEmpty(objFrm.Patient_Name) == false && string.IsNullOrEmpty(objectDTOPatient.Name) == false) { var checkPawerName = objectDTOPatient.Id + " - " + objectDTOPatient.Name; if (objFrm.Patient_Name.Trim() != checkPawerName.Trim()) { ModelState.AddModelError("Patient_Name", Translator.MsgInvalidPatientName); } } else { ModelState.AddModelError("Patient_Name", Translator.MsgInvalidPatientName); } } else { ModelState.AddModelError("Patient_Name", Translator.MsgInvalidPatientName); } var objectDisease = diseaseRepository.GetDiseaseById(objFrm.DiseaseId); if (objectDisease != null) { if (string.IsNullOrEmpty(objFrm.Disease_Name) == false && string.IsNullOrEmpty(objectDisease.Name) == false) { if (objFrm.Disease_Name.Trim() != objectDisease.Name.Trim()) { ModelState.AddModelError("Disease_Name", Translator.MsgInvalidDiseaseName); } } else { ModelState.AddModelError("Disease_Name", Translator.MsgInvalidDiseaseName); } } else { ModelState.AddModelError("Disease_Name", Translator.MsgInvalidDiseaseName); } /*End check Patient_Name,Disease_Name */ try { if (ModelState.IsValid) { Dictionary <string, string> dictItem = TransactionHelper.processGenerateArray(diagnosis); diagnosis = TransactionHelper.TransDict <Diagnosis>(dictItem, diagnosis); var objSession = Session["user"] as MyClinic.Infrastructure.SessUser; diagnosis.CreatedBy = objSession.UserId; diagnosis.DiagnoseDate = DateTime.Now; diagnosis.Status = 1; diagnosis.ExpiredDate = objFrm.ExpiredDate; Session["diagnosis"] = diagnosis; /*For Add New Record to LogTable*/ int userId = objSession.UserId; logTran.UserId = userId; logTran.ProcessType = "Add Diagnosis"; logTran.Description = "Add Diagnosis"; logTran.LogDate = DateTime.Now; logRepository.Add(logTran); checkError = false; Session["patient"] = null; return(RedirectToAction("UploadPhoto", "Diagnosis")); } } catch (Exception ex) { log.Error(ex); ModelState.AddModelError(string.Empty, Translator.UnexpectedError); } if (checkError == true) { var symptomTypes = diagnosisRepository.GetSymptomType(); var employeeLists = employeeRepository.Get(); diagnosisModel = new DiagnosisModels { diagnosisAdd = objFrm, dtopatient = objectDTOPatient, symptomTypes = symptomTypes, EmployeeLists = employeeLists, checkPost = true, checkError = false }; } return(View(diagnosisModel)); }