本文整理汇总了C#中FileManager.getDocuments方法的典型用法代码示例。如果您正苦于以下问题:C# FileManager.getDocuments方法的具体用法?C# FileManager.getDocuments怎么用?C# FileManager.getDocuments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager.getDocuments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FileManager fm = new FileManager();
GridView1.DataSource = fm.getDocuments("");
GridView1.DataBind();
}
}
示例2: searchBtn_Click
protected void searchBtn_Click(object sender, EventArgs e)
{
if (searchTB.Text != string.Empty)
{
List<Document> searchResults = new List<Document>();
//SqlConnection conn = new SqlConnection("data source=208.124.173.18;initial catalog=petomaccallum.ca;user id=sa;password=PMLsa1234;multipleactiveresultsets=True");
SqlConnection conn = new SqlConnection("data source=User;initial catalog=petomaccallum.ca;user id=sa;password=PMLtest;multipleactiveresultsets=True");
conn.Open();
SqlCommand stmt = conn.CreateCommand();
//get projnum, name, client
if (searchTB.Text.Contains(' '))
{
stmt.CommandText = "SELECT DocumentId FROM Documents WHERE FREETEXT(fileContent,@searchText)";
}
else {
stmt.CommandText = "SELECT DocumentId FROM Documents WHERE CONTAINS(fileContent,@searchText)";
}
stmt.Parameters.AddWithValue("@searchText", searchTB.Text);
TimesheetManager tm = new TimesheetManager();
SqlDataReader projectReader = stmt.ExecuteReader();
using (var context = new PetoEntities())
{
if (projectReader.HasRows)
{
while (projectReader.Read())
{
int id = projectReader.GetInt32(0);
searchResults.Add(context.Documents.FirstOrDefault(x => x.DocumentId == id));
}
}
GridView1.DataSource = searchResults;
GridView1.DataBind();
}
}
else {
FileManager fm = new FileManager();
GridView1.DataSource = fm.getDocuments("");
GridView1.DataBind();
}
}