protected void showButton_Click(object sender, EventArgs e)
        {
            DiseaseReport aDiseaseReport = new DiseaseReport();


            aDiseaseReport.DiseaseId = Convert.ToInt32(diseaseDropDownList.SelectedValue);
            int centerId = Convert.ToInt16(Session["centerId"]);

            aDiseaseReport.DistrictId = aTreatmentManager.GetDistrictIdByCenterId(centerId);
            aDiseaseReport.FromTime   = fromCalendar.SelectedDate;
            aDiseaseReport.From       = aDiseaseReport.FromTime.ToString("yyyy-MM-dd");

            aDiseaseReport.ToTime = toCalendar.SelectedDate;
            aDiseaseReport.To     = aDiseaseReport.ToTime.ToString("yyyy-MM-dd");

            List <DiseaseReport> getDiseaseReports = aDiseaseManager.GetDiseaseReport(aDiseaseReport);

            reportGridView.DataSource = getDiseaseReports;
            reportGridView.DataBind();
        }
        protected void saveButton_Click1(object sender, EventArgs e)
        {
            string msg = "";

            var diseaseList = diseaseName.Value;

            diseaseName.Value = "";
            string[] disease = diseaseList.Split(',');

            var mediceneList = medicineName.Value;

            medicineName.Value = "";
            string[] medicine = mediceneList.Split(',');

            var doseList = doseName.Value;

            doseName.Value = "";
            string[] dose = doseList.Split(',');

            var timeOfMealList = timeOfMealName.Value;

            timeOfMealName.Value = "";
            string[] timeOfMeal = timeOfMealList.Split();

            var quantityList = quantityName.Value;

            quantityName.Value = "";
            string[] quantityValue = quantityList.Split(',');


            var noteList = noteName.Value;

            noteName.Value = "";
            string[] note = noteList.Split(',');

            for (int i = 0; i < disease.Length - 1; i++)
            {
                Treatment aTreatment = new Treatment();
                string    name       = nameTextBox.Text;
                aTreatment.PatientId  = aPatientManager.Search(name).Id;
                aTreatment.DiseaseId  = aDiseaseManager.Find(disease[i]).Id;
                aTreatment.DoseId     = aDoseManager.Find(dose[i]).Id;
                aTreatment.MedicineId = aMedicineManager.Find(medicine[i]).Id;
                aTreatment.Note       = note[i];
                aTreatment.Date       = dateCalendar.SelectedDate;
                aTreatment.Quantity   = Convert.ToInt32(quantityValue[i]);
                aTreatment.CenterId   = Convert.ToInt16(Session["centerId"]);

                aTreatment.DistrictId = aTreatmentManager.GetDistrictIdByCenterId(aTreatment.DistrictId);
                aTreatment.DistrictId = 1;
                if (timeOfMeal.Equals("Before Meal"))
                {
                    aTreatment.TimeOfMeal = true;
                }
                else
                {
                    aTreatment.TimeOfMeal = false;
                }
                msg = aTreatmentManager.Save(aTreatment);
            }
            msgLabel.Text = msg;
            DataTable table = new DataTable();

            table.Clear();
            table.Columns.Add("Name", typeof(string));
            table.Columns.Add("Disease", typeof(string));
            table.Columns.Add("Medicine", typeof(string));
            table.Columns.Add("Dose", typeof(string));
            table.Columns.Add("Before/After Meal", typeof(string));
            table.Columns.Add("Quantity", typeof(int));
            table.Columns.Add("Note", typeof(string));

            for (int i = 0; i < disease.Length - 1; i++)
            {
                table.Rows.Add(nameTextBox.Text, disease[i], medicine[i], dose[i], timeOfMeal[i], quantityValue[i], note[i]);
            }
            GridView showHistoryGridView = new GridView();

            showHistoryGridView.DataSource = table.DefaultView;
            showHistoryGridView.DataBind();

            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=AllHistoryOfAPatient.pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter   aStringWriter   = new StringWriter();
            HtmlTextWriter aHtmlTextWriter = new HtmlTextWriter(aStringWriter);

            showHistoryGridView.RenderControl(aHtmlTextWriter);
            StringReader aStringReader = new StringReader(aStringWriter.ToString());
            Document     pdfDocument   = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
            HTMLWorker   aHtmlWorker   = new HTMLWorker(pdfDocument);

            PdfWriter.GetInstance(pdfDocument, Response.OutputStream);
            pdfDocument.Open();
            aHtmlWorker.Parse(aStringReader);
            pdfDocument.Close();
            Response.Write(pdfDocument);
            Response.End();
        }
Ejemplo n.º 3
0
        protected void saveButton_Click1(object sender, EventArgs e)
        {
            string msg = "";

            var diseaseList = diseaseName.Value;

            diseaseName.Value = "";
            string[] disease = diseaseList.Split(',');

            var mediceneList = medicineName.Value;

            medicineName.Value = "";
            string[] medicine = mediceneList.Split(',');

            var doseList = doseName.Value;

            doseName.Value = "";
            string[] dose = doseList.Split(',');

            var timeOfMealList = timeOfMealName.Value;

            timeOfMealName.Value = "";
            string[] timeOfMeal = timeOfMealList.Split();

            var quantityList = quantityName.Value;

            quantityName.Value = "";
            string[] quantityValue = quantityList.Split(',');


            var noteList = noteName.Value;

            noteName.Value = "";
            string[] note = noteList.Split(',');

            for (int i = 0; i < disease.Length - 1; i++)
            {
                Treatment aTreatment = new Treatment();
                string    name       = nameTextBox.Text;
                aTreatment.PatientId  = aPatientManager.Search(name).Id;
                aTreatment.DiseaseId  = aDiseaseManager.Find(disease[i]).Id;
                aTreatment.DoseId     = aDoseManager.Find(dose[i]).Id;
                aTreatment.MedicineId = aMedicineManager.Find(medicine[i]).Id;
                aTreatment.Note       = note[i];
                aTreatment.Date       = dateCalendar.SelectedDate;
                aTreatment.Quantity   = Convert.ToInt32(quantityValue[i]);
                aTreatment.CenterId   = Convert.ToInt16(Session["centerId"]);

                aTreatment.DistrictId = aTreatmentManager.GetDistrictIdByCenterId(aTreatment.DistrictId);
                aTreatment.DistrictId = 1;
                if (timeOfMeal.Equals("Before Meal"))
                {
                    aTreatment.TimeOfMeal = true;
                }
                else
                {
                    aTreatment.TimeOfMeal = false;
                }
                msg = aTreatmentManager.Save(aTreatment);
            }
            msgLabel.Text = msg;
        }