예제 #1
0
        protected void GenerateDynamicGridView()
        {
            gvDynamicReport.DataSource = null;
            gvDynamicReport.Columns.Clear();

            string    CompanyName = VNull.IsNull(txtCompanyName.Text) ? null : txtCompanyName.Text;
            DateTime  startDate   = VNull.IsNull(startdate.Text) ? VNull.NullDateTime : Convert.ToDateTime(startdate.Text + " 00:00:00");
            DateTime  endDate     = VNull.IsNull(enddate.Text) ? VNull.NullDateTime : Convert.ToDateTime(enddate.Text + " 00:00:00");
            int       reportId    = Convert.ToInt32(ddlSelectReport.SelectedValue.ToString());
            DataTable dt          = new DataTable();

            using (SqlConnection con = new SqlConnection(ConfigEMRCheckUp.ConfigCls.PathwayConnString))
            {
                con.Open();
                string storeName = "dbo.CorpRpt_DynamicLabGroup";

                if (reportId == 4)
                {
                    storeName = "CorpRpt_DynamicLabGroup_Urine_Stool";
                }

                SqlCommand cmd = new SqlCommand(storeName, con);
                cmd.Parameters.AddWithValue("@companyname", CompanyName);
                cmd.Parameters.AddWithValue("@startdate", startDate);
                cmd.Parameters.AddWithValue("@enddate", endDate);
                cmd.Parameters.AddWithValue("@labgroup", reportId);
                cmd.CommandType = CommandType.StoredProcedure;

                using (var da = new SqlDataAdapter(cmd))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    da.Fill(dt);
                }
                con.Close();
                con.Dispose();
            }

            foreach (DataColumn dc in dt.Columns)
            {
                BoundField bField = new BoundField();
                bField.HeaderText = dc.ColumnName;
                bField.DataField  = dc.ColumnName;
                if (dc.ColumnName.Contains("RBC Morphology"))
                {
                    bField.HeaderStyle.Width = Unit.Pixel(220);
                    bField.ItemStyle.Width   = Unit.Pixel(220);
                }
                gvDynamicReport.Columns.Add(bField);
            }

            gvDynamicReport.DataSource = dt;
            gvDynamicReport.DataBind();
        }
예제 #2
0
        protected void GeneratePatientsGridView()
        {
            gvShowPatients.DataSource = null;
            string   total       = "0";
            string   patients    = "0";
            string   companyName = VNull.IsNull(txtCompanyName.Text) ? "" : txtCompanyName.Text;
            DateTime startDate   = VNull.IsNull(startdate.Text) ? VNull.NullDateTime : Convert.ToDateTime(startdate.Text + " 00:00:00");
            DateTime endDate     = VNull.IsNull(enddate.Text) ? VNull.NullDateTime : Convert.ToDateTime(enddate.Text + " 00:00:00");

            DataTable      dt = new DataTable();
            List <patient> pt = null;

            using (InhCheckupDataContext cdc = new InhCheckupDataContext())
            {
                total = cdc.vw_patient_corporates
                        .Where(x => (x.companyname == null ? "" : x.companyname) == companyName &&
                               x.arrived_date.Value.Date >= startDate &&
                               x.arrived_date.Value.Date <= endDate)
                        .Count().ToString();

                using (InhToDoListDataContext itc = new InhToDoListDataContext())
                {
                    string sub_com = "";
                    if (!string.IsNullOrEmpty(companyName))
                    {
                        var doc_no = (from itd in itc.index_trn_company_details
                                      join tcd in itc.trn_company_details
                                      on itd.tcd_id equals tcd.tcd_id
                                      where tcd.tcd_tname == companyName
                                      select itd.tcd_document_no).FirstOrDefault();

                        sub_com = (from tcd in itc.trn_company_details
                                   join itd in itc.index_trn_company_details
                                   on tcd.tcd_id equals itd.tcd_id
                                   where tcd.tcd_document_no == doc_no
                                   select tcd.tcd_legal).FirstOrDefault();

                        txtSubCompanyName.Text = sub_com;

                        if (!string.IsNullOrEmpty(doc_no))
                        {
                            pt = cdc.trn_patient_book_covers
                                 .Where(x => x.tcd_document_no == doc_no && x.trn_patient_regi.tpr_arrive_date.Value.Date >= startDate.Date &&
                                        x.trn_patient_regi.tpr_arrive_date.Value.Date <= endDate.Date)
                                 .Select(x => new patient
                            {
                                HN      = x.trn_patient_regi.trn_patient.tpt_hn_no,
                                ID      = x.trn_patient_regi.trn_patient_book_cover.tpbc_emp_id,
                                Name    = x.trn_patient_regi.trn_patient.tpt_othername,
                                Arrived = x.trn_patient_regi.trn_patient_regis_detail.tpr_real_arrived_date.Value
                            }).OrderBy(x => x.Arrived).ToList();

                            patients = pt.Count().ToString();
                        }
                    }
                }
            }

            dt = ToDataTable(pt);
            dt.Columns.Add("No", typeof(int));
            int i = 0;

            foreach (DataRow dr in dt.Rows)
            {
                i        = i + 1;
                dr["No"] = i;
            }

            txtTotalPatients.Text   = total;
            txtArrivedPatients.Text = patients;

            gvShowPatients.DataSource = dt;
            gvShowPatients.DataBind();
        }