private void BuildGrid() { pager = new MyDataGridPager(); pager.NumberRowsToDisplay = 10; DataGridObject dataGridObj = new DataGridObject(WebConfigurationManager.ConnectionStrings["MyTherapistDatabaseConnectionString"].ConnectionString, "PatientAppointmentInformation"); DatabaseRowObject dbRowObject = new DatabaseRowObject(); dbRowObject.AddColumn("ApptDate", "Appointment Date", MyDataTypes.DATETIME, true, 35, false); dbRowObject.AddColumn("ApptId", "", MyDataTypes.GUID, true, 35, false); dbRowObject.AddColumn("RLU", "RLU", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("SP", "SP", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("KD1", "KD", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("LHT", "LHT", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("LV", "LV", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("KD2", "KD ", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("ImageBeforeTherapy", "", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("ImageAfterTherapy", "", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("TherapyPerformed", "", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("SessionGoals", "", MyDataTypes.STRING, false, 0, true); dbRowObject.AddColumn("Name", "", MyDataTypes.STRING, false, 0, true, "Therapists", "TherapistId", "Id"); dataGridObj.DatabaseRowObject = dbRowObject; if (IsPostBack == false) { Session["PatientHistorySortOrder"] = "DESC"; pager.Sort = MyDataSort.DESC; } else { if (Session["PatientHistorySortOrder"] != null) { if (Session["PatientHistorySortOrder"].ToString() == "DESC") { pager.Sort = MyDataSort.DESC; } else { pager.Sort = MyDataSort.ASC; } } } dataGridObj.AddWhereClauseArgument("PatientId", Session[CommonDefinitions.CommonDefinitions.PATIENT_ID].ToString()); LinkButton linkButtonPatient = null; LinkButton linkButtonApptDate = null; TableRow row = new TableRow(); TableCell cell = new TableCell(); linkButtonPatient = new LinkButton(); if ((Session["PatientFirstName"] != null) && (Session["PatientLastName"] != null)) { linkButtonPatient.Text = String.Format("{0} {1} DOB: {2}", Session["PatientFirstName"].ToString(), Session["PatientLastName"].ToString(), Session["PatientBirthDate"].ToString()); } linkButtonPatient.Command += linkButtonPatient_Command; linkButtonPatient.CommandArgument = Session["PatientId"].ToString(); cell.Controls.Add(linkButtonPatient); row.Cells.Add(cell); PatientApptData.Rows.Add(row); // spacer row = new TableRow(); cell = new TableCell(); cell.Text = " "; cell.ColumnSpan = 7; row.Cells.Add(cell); PatientApptData.Rows.Add(row); DataTable appointmentInfo = dataGridObj.BuildTable(); DataRow dataRow = null; System.Collections.IEnumerator iter = null; if (appointmentInfo.Rows.Count == 0) { row = new TableRow(); cell = new TableCell(); Label label = new Label(); label.Text = "No Appointments Found"; cell.Controls.Add(label); row.Cells.Add(cell); PatientApptData.Rows.Add(row); } else { iter = appointmentInfo.Rows.GetEnumerator(); while (iter.MoveNext()) { row = new TableRow(); cell = new TableCell(); Image img = null; cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); cell = new TableCell(); cell.Style["font-weight"] = "bold"; cell.Text = "RLU"; row.Cells.Add(cell); cell = new TableCell(); cell.Text = "SP"; cell.Style["font-weight"] = "bold"; row.Cells.Add(cell); cell = new TableCell(); cell.Style["font-weight"] = "bold"; cell.Text = "KD1"; row.Cells.Add(cell); cell = new TableCell(); cell.Style["font-weight"] = "bold"; cell.Text = "LHT"; row.Cells.Add(cell); cell = new TableCell(); cell.Style["font-weight"] = "bold"; cell.Text = "LV"; row.Cells.Add(cell); cell = new TableCell(); cell.Style["font-weight"] = "bold"; cell.Text = "KD2"; row.Cells.Add(cell); PatientApptData.Rows.Add(row); dataRow = (DataRow)iter.Current; row = new TableRow(); cell = new TableCell(); linkButtonApptDate = new LinkButton(); linkButtonApptDate.Text = dataRow.ItemArray[0].ToString(); linkButtonApptDate.Command += linkButtonApptDate_Command; linkButtonApptDate.CommandArgument = dataRow.ItemArray[dbRowObject.ColumnIndex("ApptId")].ToString(); cell.Controls.Add(linkButtonApptDate); row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("RLU")].ToString(); row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("SP")].ToString(); row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("KD1")].ToString(); row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("LHT")].ToString(); row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("LV")].ToString(); row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("KD2")].ToString(); row.Cells.Add(cell); cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); PatientApptData.Rows.Add(row); row = new TableRow(); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("Name")].ToString();; cell.VerticalAlign = VerticalAlign.Top; row.Cells.Add(cell); cell = new TableCell(); cell.ColumnSpan = 3; img = new Image(); img.ImageUrl = dataRow.ItemArray[dbRowObject.ColumnIndex("ImageBeforeTherapy")].ToString(); img.ImageAlign = ImageAlign.Middle; img.Width = IMAGE_WIDTH; img.Height = IMAGE_HEIGHT; cell.HorizontalAlign = HorizontalAlign.Left; cell.Controls.Add(img); row.Cells.Add(cell); cell = new TableCell(); cell.ColumnSpan = 3; cell.Text = " "; cell = new TableCell(); cell.ColumnSpan = 3; img = new Image(); img.ImageUrl = dataRow.ItemArray[dbRowObject.ColumnIndex("ImageAfterTherapy")].ToString(); img.ImageAlign = ImageAlign.Middle; img.Width = IMAGE_WIDTH; img.Height = IMAGE_HEIGHT; cell.HorizontalAlign = HorizontalAlign.Left; cell.Controls.Add(img); row.Cells.Add(cell); PatientApptData.Rows.Add(row); // spacer row = new TableRow(); cell = new TableCell(); cell.Text = " "; cell.ColumnSpan = 7; row.Cells.Add(cell); PatientApptData.Rows.Add(row); /// therapy performed row = new TableRow(); cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); cell = new TableCell(); cell.Text = "Therapy Performed"; cell.ColumnSpan = 5; cell.Style["font-weight"] = "bold"; row.Cells.Add(cell); cell = new TableCell(); cell.Text = "Session Goals"; cell.ColumnSpan = 5; cell.Style["font-weight"] = "bold"; row.Cells.Add(cell); PatientApptData.Rows.Add(row); row = new TableRow(); cell = new TableCell(); cell.Text = " "; row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("TherapyPerformed")].ToString(); cell.ColumnSpan = 5; row.Cells.Add(cell); cell = new TableCell(); cell.Text = dataRow.ItemArray[dbRowObject.ColumnIndex("SessionGoals")].ToString(); cell.ColumnSpan = 5; row.Cells.Add(cell); PatientApptData.Rows.Add(row); // spacer for (int spacercount = 1; spacercount <= 2; spacercount++) { row = new TableRow(); cell = new TableCell(); cell.Text = " "; cell.ColumnSpan = 10; row.Cells.Add(cell); PatientApptData.Rows.Add(row); } } } }
public void LoadGrid() { DatabaseRowObject.DatabaseColumnObject databaseColumnObj = null; dataGridObject = new DataGridObject(WebConfigurationManager.ConnectionStrings["MyTherapistDatabaseConnectionString"].ConnectionString, "PatientInformation"); databaseRowObject = new DatabaseRowObject(); databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject(); databaseColumnObj.DataBaseTableColumnName = "Id"; databaseColumnObj.DataGridColumnName = "Id"; databaseColumnObj.DataType = MyDataTypes.INTEGER; databaseColumnObj.IncludeInDataGrid = true; databaseColumnObj.OrderByColumn = true; databaseColumnObj.Encrypted = false; databaseRowObject.AddColumn(databaseColumnObj); databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject(); databaseColumnObj.DataBaseTableColumnName = "FirstName"; databaseColumnObj.DataGridColumnName = "First Name"; databaseColumnObj.DataType = MyDataTypes.STRING; databaseColumnObj.IncludeInDataGrid = true; databaseColumnObj.OrderByColumn = false; databaseColumnObj.Encrypted = false; databaseRowObject.AddColumn(databaseColumnObj); databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject(); databaseColumnObj.DataBaseTableColumnName = "LastName"; databaseColumnObj.DataGridColumnName = "Last Name"; databaseColumnObj.DataType = MyDataTypes.STRING; databaseColumnObj.IncludeInDataGrid = true; databaseColumnObj.OrderByColumn = false; databaseColumnObj.Encrypted = false; databaseRowObject.AddColumn(databaseColumnObj); databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject(); databaseColumnObj.DataBaseTableColumnName = "BirthDate"; databaseColumnObj.DataGridColumnName = "BirthDate"; databaseColumnObj.DataType = MyDataTypes.STRING; databaseColumnObj.DisplayType = MyDisplayTypes.DATE; databaseColumnObj.IncludeInDataGrid = true; databaseColumnObj.OrderByColumn = false; databaseColumnObj.Encrypted = true; databaseRowObject.AddColumn(databaseColumnObj); databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject(); databaseColumnObj.DataBaseTableColumnName = "EmailAddress"; databaseColumnObj.DataGridColumnName = "Email Address"; databaseColumnObj.DataType = MyDataTypes.STRING; databaseColumnObj.IncludeInDataGrid = true; databaseColumnObj.OrderByColumn = false; databaseColumnObj.Encrypted = true; databaseRowObject.AddColumn(databaseColumnObj); databaseColumnObj = new DatabaseRowObject.DatabaseColumnObject(); databaseColumnObj.DataBaseTableColumnName = "TelephoneNumber"; databaseColumnObj.DataGridColumnName = "Telephone Number"; databaseColumnObj.DataType = MyDataTypes.STRING; databaseColumnObj.IncludeInDataGrid = true; databaseColumnObj.OrderByColumn = false; databaseColumnObj.Encrypted = true; databaseRowObject.AddColumn(databaseColumnObj); dataGridObject.DatabaseRowObject = databaseRowObject; dataGridObject.FillToCompletePage = true; dataGridObject.PageNumber = 1; dataGridObject.NumberRowsToDisplay = 15; pager = new MyDataGridPager(); pager.AddColumn("Id", 15); pager.AddColumn("First Name", 25); pager.AddColumn("Last Name", 250); pager.AddColumn("Email Address", 250); pager.AddColumn("Telephone Number", 100); if (txtBoxPatientFirstName.Text.Length > 0) { dataGridObject.AddWhereClauseArgument("FirstName", txtBoxPatientFirstName.Text); } if (txtBoxPatientLastName.Text.Length > 0) { dataGridObject.AddWhereClauseArgument("LastName", txtBoxPatientLastName.Text); } if (IsPostBack == false) { dataGridObject.PageNumber = 1; Session["PatientList_PageNumber"] = "1"; } else { dataGridObject.PageNumber = Int32.Parse(Session["PatientList_PageNumber"].ToString()); } patientlistgridview.DataSource = dataGridObject.BuildTable(); patientlistgridview.RowDataBound += Patientlistgridview_RowDataBound; patientlistgridview.SelectedIndexChanged += Patientlistgridview_SelectedIndexChanged; patientlistgridview.DataBind(); if (dataGridObject.NumberOfCompletedPages == 0) { btnNextPAge.Enabled = false; } else { btnNextPAge.Enabled = true; } }