私はこのコードを持っていますが、機能していません..何もフィルタリングしません..何かを生成するとき..理由がわかりません..誰かがこれを修正するのを手伝ってくれます..?? 何かを生成する必要があります。ここに私が使用しているコードがあります:
public DataTable getDocumentsByFilter(string category, string document, string office, string period, DateTime start, DateTime end, string sy, string sem, string searchinfo)
{
string sql = "SELECT d.*,so.*,sy.*,ua.*,so.SchoolOfficeDescription as [AddresseeName] From Document d, SchoolOffice so, SchoolYear sy, UserAccount ua WHERE d.Addressee = so.SchoolOfficeID AND d.SchoolYearID = sy.SchoolYearID AND d.Status like 'Active' AND ua.UserID = d.UserID";
if (!(office == "All"))
{
sql = sql + " And d.Addressee =" + office ;
}
else if (office == "All")
{
sql = sql + " AND d.Addressee >= 0 ";
}
if (!(document == "All"))
{
sql = sql + document + "";
}
else
{
sql = sql + " AND ( d.docStatus like 'Draft' OR d.docStatus like 'Forwarded' OR d.docStatus like 'Received') ";
}
if (!(category == "All"))
sql = sql + " And d.Category like '" + category+ "'";
else
{
sql = sql + " AND ( d.Category like 'Activity,Item,Service' OR d.Category like 'Activity' OR d.Category like 'Item' or d.Category like 'Service')";
}
if (period == "SY")
{
sql = sql + " And sy.YearStart like '" + sy + "'";
if (!(sem == "Please select..."))
{
sql = sql + " And sy.Semester like '" + sem + "'";
}
else
{
sql = sql + " And (sy.Semester like 'First Semester' OR sy.Semester like 'Summer Term' or sy.Semester like 'Second Semester') ";
}
}
else if (period == "Date")
{
sql = sql + " And d.DateCreated between '" + start + "' And '" + end + "'";
}
else if (period == "All")
{
sql = sql + " AND d.DateCreated > '1/1/1911 12:00:00 AM' ";
}
if (searchinfo != "Enter document details")
{
sql = sql + " AND ((ua.FirstName like '%" + searchinfo + "%' OR ua.LastName like '%" + searchinfo + "%') AND ua.UserID = d.UserID)";
}
sql = sql + " ORDER BY d.DateCreated DESC";
return GetDataTable(sql, null);
}