private string BuildSQL(bool isCount, FormSearchMode searchMode) { eligibility_data ed = new eligibility_data(); string sql; if (isCount) { sql = string.Format("SELECT COUNT(*) FROM eligibility_data WHERE CAST(appt_date AS DATE) >= Cast(GetDate() AS DATE) ", nmbMaxResults.Value.ToString()); } else { sql = string.Format("SELECT TOP {0} * FROM eligibility_data WHERE CAST(appt_date AS DATE) >= Cast(GetDate() AS DATE) ", nmbMaxResults.Value.ToString()); } if (searchMode == FormSearchMode.Unsent) { sql += " AND (last_check = null OR last_check < '1-2-1900')"; } else if (searchMode == FormSearchMode.Tomorrow) { sql += string.Format(" AND CAST(appt_date AS DATE) = CAST('{0}' AS DATE)", DateTime.Today.AddDays(1)); } else if (searchMode == FormSearchMode.AllUpcoming) { sql += ""; // No additional criteria required } else if (searchMode == FormSearchMode.Rejected) { sql += " AND last_check > '1-2-1900' AND last_status = 0"; } else if (searchMode == FormSearchMode.Sent) { sql += " AND last_check > '1-2-1900' AND last_status = 2"; } if (!isCount) { sql += " ORDER BY appt_date asc"; } return(sql); }
private void SetButtonAppearance(Button toHighlight) { List <Button> allButtons = new List <Button>(new Button[] { btnTomorrow, btnUpcoming, btnUnverified, btnRejected, btnSent }); foreach (Button aButton in allButtons) { if (aButton == toHighlight) { aButton.FlatStyle = FlatStyle.Flat; aButton.BackColor = Color.Thistle; if (aButton == btnTomorrow) { _searchMode = FormSearchMode.Tomorrow; } else if (aButton == btnUpcoming) { _searchMode = FormSearchMode.AllUpcoming; } else if (aButton == btnUnverified) { _searchMode = FormSearchMode.Unsent; } else if (aButton == btnRejected) { _searchMode = FormSearchMode.Rejected; } else if (aButton == btnSent) { _searchMode = FormSearchMode.Sent; } } else { aButton.FlatStyle = FlatStyle.Standard; aButton.BackColor = System.Drawing.SystemColors.Control; } } }