Example #1
0
        private void LoadLabAll()
        {
            int idata = 0;

            try
            {
                var    objHN = (from t1 in dbc.trn_patient_regis where t1.tpr_id == Program.CurrentRegis.tpr_id select t1).FirstOrDefault();
                string hn;

                if (objHN != null)
                {
                    hn = objHN.trn_patient.tpt_hn_no;

                    DataTable dt = new DataTable();
                    dt.TableName = "lab";
                    dt.Columns.Add("no");
                    dt.Columns.Add("labno");
                    dt.Columns.Add("labname");
                    var objCol = (from t1 in dbc.sp_top5appointment_lab(hn) select t1).ToList();
                    for (int i = 0; i < objCol.Count; i++)
                    {
                        dt.Columns.Add(String.Format("{0:dd/MM/yyyy}", objCol[i].labdate));
                    }

                    var objRow = (from t1 in dbc.sp_hrow_appoint_lab(hn) select t1).ToList();
                    for (int j = 0; j < objRow.Count; j++)
                    {
                        dt.Rows.Add(j + 1, objRow[j].tpl_lab_no, objRow[j].tpl_lab_name);
                    }


                    int row = 0;
                    for (int k = 0; k < dt.Columns.Count; k++)
                    {
                        if (k > 2)
                        {
                            var objdata = (from t1 in dbc.sp_detail_appoint_lab(objCol[row++].labdate, hn) select t1).ToList();
                            for (int q = 0; q < objdata.Count; q++)
                            {
                                DataRow[] rowdata = dt.Select("labno = '" + objdata[q].tpl_lab_no + "'");

                                foreach (DataRow data in rowdata)
                                {
                                    data[k] = objdata[q].tpl_lab_value;
                                }

                                idata = q;
                            }
                        }
                    }

                    dt.AcceptChanges();
                    GvLab.DataSource = dt;

                    GvLab.Columns[0].Width = 50;
                    GvLab.Columns[1].Width = 50;
                    GvLab.Columns[2].Width = 150;

                    GvLab.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    //GvLab.Columns[1].Visible = false;
                    GvLab.Columns[2].DefaultCellStyle.BackColor = Color.LavenderBlush;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " Error >>> iRow at : " + idata);
            }
        }