private void RunSearch() { // need validation here too // because date is validated in the front-end but only when they leave the control if (ValidateDates()) { this.errorMessage.Visible = false; DataTable dt = null; SpecimenManagerDa da = new SpecimenManagerDa(); dt = da.GetCollectionByName(this.collectionName.Value); dt = da.GetCollections(this.collectionName.Value, this.ddlType.Value, this.ddlStatus.Value, this.dateFrom.Value, this.dateTo.Value, this.chkViewAll.Checked); //} this.lblTotalCollections.Text = dt.Rows.Count.ToString() + " collection record(s) matched your search criteria"; if (dt.Rows.Count == 1) { Response.Redirect("Collection.aspx?colId=" + dt.Rows[0][SpecimenCollection.CollectionId].ToString() + "&isSingleResult=true" + BuildQuerySearch()); } if (dt.Rows.Count > 0) { this.noCollectionsRow.Visible = false; this.searchBody.Visible = true; this.resultsMsg.Visible = true; this.rptCollection.DataSource = dt.DefaultView; this.rptCollection.DataBind(); } else { this.noCollectionsRow.Visible = true; this.searchBody.Visible = true; this.resultsMsg.Visible = false; this.rptCollection.DataSource = null; this.rptCollection.DataBind(); } } else { ShowMessage(this.errorMessage, "Please enter a valid date.", "red"); this.errorMessage.Visible = true; this.resultsMsg.Visible = false; this.searchBody.Visible = false; } }
/// <summary> /// Sorting Collection repeater using headers in ascending & descending order /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void rptSort(object sender, CommandEventArgs e) { SpecimenManagerDa da = new SpecimenManagerDa(); DataTable dt = da.GetCollections(this.collectionName.Value, this.ddlType.Value, this.ddlStatus.Value, this.dateFrom.Value, this.dateTo.Value, this.chkViewAll.Checked); switch (e.CommandName) { case "Name": if (Name.ToolTip == "Click to sort descending") { dt.DefaultView.Sort = "CollectionName Desc"; Name.ToolTip = "Click to sort ascending"; } else { dt.DefaultView.Sort = "CollectionName Asc"; Name.ToolTip = "Click to sort descending"; } break; case "Type": if (ColType.ToolTip == "Type" || ColType.ToolTip == "Click to sort ascending") { dt.DefaultView.Sort = "CollectionType"; ColType.ToolTip = "Click to sort descending"; } else if (ColType.ToolTip == "Click to sort descending") { dt.DefaultView.Sort = "CollectionType Desc"; ColType.ToolTip = "Click to sort ascending"; } break; case "Status": if (Status.ToolTip == "Status" || Status.ToolTip == "Click to sort ascending") { dt.DefaultView.Sort = "CollectionStatus"; Status.ToolTip = "Click to sort descending"; } else if (Status.ToolTip == "Click to sort descending") { dt.DefaultView.Sort = "CollectionStatus Desc"; Status.ToolTip = "Click to sort ascending"; } break; case "Specimens": if (Specimens.ToolTip == "#Specimens" || Specimens.ToolTip == "Click to sort ascending") { dt.DefaultView.Sort = "SpecimensInCollection"; Specimens.ToolTip = "Click to sort descending"; } else if (Specimens.ToolTip == "Click to sort descending") { dt.DefaultView.Sort = "SpecimensInCollection Desc"; Specimens.ToolTip = "Click to sort ascending"; } break; case "DateCreated": if (DateCreated.ToolTip == "Date" || DateCreated.ToolTip == "Click to sort ascending") { dt.DefaultView.Sort = "CollectionAssignDate" + " Asc"; DateCreated.ToolTip = "Click to sort descending"; } else if (DateCreated.ToolTip == "Click to sort descending") { dt.DefaultView.Sort = "CollectionAssignDate" + " Desc"; DateCreated.ToolTip = "Click to sort ascending"; } break; } rptCollection.DataSource = dt; rptCollection.DataBind(); }