Esempio n. 1
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            int     districtId = int.Parse(Session["DistrictId"].ToString());
            Patient aPatient   = new Patient();

            aPatient.VoterId = voterIdTextBox.Text;
            int count = int.Parse(serviceGivenTextBox.Text);

            aPatient.ServiceTimes = count + 1;
            if (patientManager.IfPatientExists(aPatient))
            {
                megLabel.Text = patientManager.UpdateServiceTimes(aPatient);
                AllClear();
            }
            else
            {
                megLabel.Text = patientManager.SavePatient(aPatient);
                AllClear();
            }

            aPatient.Id = patientManager.GetPatientId(aPatient);
            int centerId = int.Parse(Session["CenterId"].ToString());

            patientManager.PatientCenterTblValue(aPatient.Id, centerId, districtId);

            Treatment aTreatment = new Treatment();

            aTreatment.Observation = observationTextBox.Text;
            aTreatment.DoctorId    = int.Parse(doctorDropDownList.SelectedValue);
            string date  = Request.Form["bday"];
            int    year  = int.Parse(date.Substring(0, 4));
            int    month = int.Parse(date.Substring(5, 2));
            int    day   = int.Parse(date.Substring(8, 2));

            aTreatment.Date = year + "-" + month + "-" + day;

            int observationId = treatmentManager.SaveObservation(aTreatment, aPatient, centerId);

            foreach (var treatment in TreatmentList)
            {
                Treatment newTreatment = new Treatment();
                newTreatment.DiseaseId  = treatment.DiseaseId;
                newTreatment.MedicineId = treatment.MedicineId;
                newTreatment.Dose       = treatment.Dose;
                newTreatment.Quantity   = treatment.Quantity;
                newTreatment.Note       = treatment.Note;
                newTreatment.TakenTime  = treatment.TakenTime;
                treatmentManager.SaveTreatment(newTreatment, observationId);
            }
        }