protected void GridView_BookListStartBind() //为GridView绑定数据 { DataSet DtClass = SqlHelper.ExecuteDataset(CommandType.Text, "SELECT * FROM [BookClass].[dbo].[ClassList]"); GridView_BookList.DataSourceID = null; GridView_BookList.DataSource = DtClass.Tables[0]; GridView_BookList.DataKeyNames = new string[] { "ID" }; GridView_BookList.DataBind(); }
protected void GridView_BookListBind() //为GridView绑定数据 { if (Drop_Address.SelectedValue == "——请选择——") { Response.Write("<script>alert('请选择教室地址和编号!')</script>"); return; } DataSet DtClass = SqlHelper.ExecuteDataset(CommandType.Text, "SELECT * FROM [BookClass].[dbo].[ClassList] WHERE [Address]='" + Drop_Address.SelectedValue + "'"); GridView_BookList.DataSourceID = null; GridView_BookList.DataSource = DtClass.Tables[0]; GridView_BookList.DataBind(); }
protected void GridView_BookListStartBind() //初始时为GridView绑定数据 { DataSet DtBook = SqlHelper.ExecuteDataset(CommandType.Text, "SELECT * FROM [BookClass].[dbo].[BookList] WHERE BookDate = '" + DateTime.Now.ToLongDateString() + "'AND IsBooked ='等待管理员通过'"); for (int i = 1; i <= BookDay; i++) { DataSet DtBook1 = SqlHelper.ExecuteDataset(CommandType.Text, "SELECT * FROM [BookClass].[dbo].[BookList] WHERE BookDate = '" + DateTime.Now.AddDays(i).ToLongDateString() + "'AND IsBooked ='等待管理员通过'"); DtBook.Merge(DtBook1); } GridView_BookList.DataSource = DtBook; GridView_BookList.DataKeyNames = new string[] { "ID" }; //给前端控件指定主键 GridView_BookList.DataBind(); }
protected void GridView_BookListBind() //为GridView绑定数据 { if (Drop_Address.SelectedValue == "——请选择——") { Response.Write("<script>alert('请选择教室地址和编号!')</script>"); return; } DataSet DtClass = SqlHelper.ExecuteDataset(CommandType.Text, "SELECT * FROM [BookClass].[dbo].[ClassList] WHERE [Address]='" + Drop_Address.SelectedValue + "' AND [ClassNum] ='" + Drop_ClassNum.SelectedValue + "'"); SqlDataAdapter AdaBook = new SqlDataAdapter("SELECT ID,Address,ClassNum,BookDate,StartTime,EndTime , IsBooked FROM [BookList]", strcon); DataTable DtBook = new DataTable(); AdaBook.Fill(DtBook); DataTable DtGrid = DtBook; DtGrid.Rows.Clear(); string[] DayStartClock = new string[] { "8:00", "10:00", "12:00", "14:00", "16:00", "19:00", "21:00" }; string[] DayEndClock = new string[] { "10:00", "12:00", "14:00", "16:00", "18:00", "21:00", "23:00" }; DateTime AssStartDate = Convert.ToDateTime(Drop_StartTime.SelectedValue); DateTime AssEndDate = Convert.ToDateTime(Drop_StartTime.SelectedValue); int RowsCount = 0; for (int i = 0; i < DtClass.Tables[0].Rows.Count; i++) { for (int k = 0; k <= BookDay; k++) { DateTime RAssDate = AssStartDate.AddDays(k); for (int l = 0; l < DayStartClock.Count(); l++) //按时段检索修改DtGrid { RowsCount += 1; DataSet DsBook = SqlHelper.ExecuteDataset(CommandType.Text, "SELECT * FROM [BookClass].[dbo].[BookList] WHERE [Address] = '" + DtClass.Tables[0].Rows[i]["Address"] + "' AND ClassNum = '" + DtClass.Tables[0].Rows[i]["ClassNum"] + "' AND BookDate = '" + RAssDate.ToLongDateString() + "' AND StartTime = '" + DayStartClock[l] + "' AND IsBooked <>'3'"); if (DsBook.Tables[0].Rows.Count > 0) { DtGrid.Rows.Add(RowsCount, DtClass.Tables[0].Rows[i]["Address"], DtClass.Tables[0].Rows[i]["ClassNum"], RAssDate.ToLongDateString(), DayStartClock[l], DayEndClock[l], "已预约"); } else { DtGrid.Rows.Add(RowsCount, DtClass.Tables[0].Rows[i]["Address"], DtClass.Tables[0].Rows[i]["ClassNum"], RAssDate.ToLongDateString(), DayStartClock[l], DayEndClock[l], "可预约"); } } if (RAssDate.ToLongDateString() == Drop_EndTime.SelectedValue) { break; } } } GridView_BookList.DataSource = DtGrid; GridView_BookList.DataKeyNames = new string[] { "ID" }; GridView_BookList.DataBind(); }
protected void GridView_BookListBind() //为GridView绑定数据 { if (Drop_Address.SelectedValue == "——请选择——") { Response.Write("<script>alert('请选择教室地址和编号!')</script>"); return; } DataSet DtBook = SqlHelper.ExecuteDataset(CommandType.Text, "SELECT * FROM [BookClass].[dbo].[BookList] WHERE [Address]='" + Drop_Address.SelectedValue + "' AND [ClassNum] ='" + Drop_ClassNum.SelectedValue + "' AND BookDate = '" + DateTime.Now.ToLongDateString() + "'AND IsBooked ='等待管理员通过'"); for (int i = 1; i <= BookDay; i++) { DataSet DtBook1 = SqlHelper.ExecuteDataset(CommandType.Text, "SELECT * FROM [BookClass].[dbo].[BookList] WHERE [Address]='" + Drop_Address.SelectedValue + "' AND [ClassNum] ='" + Drop_ClassNum.SelectedValue + "' AND BookDate = '" + DateTime.Now.AddDays(i).ToLongDateString() + "' AND IsBooked ='等待管理员通过'"); DtBook.Merge(DtBook1); } GridView_BookList.DataSource = DtBook; GridView_BookList.DataKeyNames = new string[] { "ID" }; GridView_BookList.DataBind(); }