protected void 二级单位_SelectedIndexChanged(object sender, EventArgs e) { //string 起始日期 = ""; //string 截止日期 = ""; //try //{ // 起始日期 = DatePicker1.SelectedDate.Value.ToString("yyyy-MM-dd"); // 截止日期 = DatePicker2.SelectedDate.Value.ToString("yyyy-MM-dd"); //} //catch (Exception) //{ // 起始日期 = ""; // 截止日期 = ""; //} int ID = Convert.ToInt32(二级单位.SelectedValue); int year = 0; if (年份.SelectedText == "" || 年份.SelectedText == null) { DateTime dt = DateTime.Now; year = dt.Year; } else { year = int.Parse(年份.SelectedText); } //GridGZ.DataSource = gzbll.按各单位查询设备故障(0, "", "", "", dt.Year, GridGZ.PageIndex, GridGZ.PageSize); GridGZ.RecordCount = gzbll.查询设备故障总数(ID, ttbSearch.Text, year); GridGZ.DataSource = gzbll.各单位查询设备故障(ID, ttbSearch.Text, year, GridGZ.PageIndex, GridGZ.PageSize); GridGZ.DataBind(); }
private void BindGrid() { // 1.设置总项数(特别注意:数据库分页一定要设置总记录数RecordCount) DateTime dt = DateTime.Now; GridGZ.RecordCount = gzbll.查询设备故障总数(0, "", dt.Year); GridGZ.DataSource = gzbll.各单位查询设备故障(0, "", dt.Year, GridGZ.PageIndex, GridGZ.PageSize); GridGZ.DataBind(); }
protected void SelectContentBtn_Click(object sender, EventArgs e) { //string 起始日期 = ""; //string 截止日期 = ""; //try //{ // 起始日期 = DatePicker1.SelectedDate.Value.ToString("yyyy-MM-dd"); // 截止日期 = DatePicker2.SelectedDate.Value.ToString("yyyy-MM-dd"); // DateTime dt1 = Convert.ToDateTime(起始日期); // DateTime dt2 = Convert.ToDateTime(截止日期); // if (dt2 < dt1) // { // Alert.ShowInTop("截止日期不能小于起始日期!", MessageBoxIcon.Error); // return; // } //} //catch (Exception) //{ // 起始日期 = ""; // 截止日期 = ""; //} int year = 0; if (年份.SelectedText == "") { DateTime dt = DateTime.Now; year = dt.Year; } else { year = int.Parse(年份.SelectedText); } int ID = Convert.ToInt32(二级单位.SelectedValue); GridGZ.RecordCount = gzbll.查询设备故障总数(ID, ttbSearch.Text, year); GridGZ.DataSource = gzbll.各单位查询设备故障(ID, ttbSearch.Text, year, GridGZ.PageIndex, GridGZ.PageSize); GridGZ.DataBind(); }
protected void GridGZ_PageIndexChange(object sender, GridPageEventArgs e) { int ID = Convert.ToInt32(二级单位.SelectedValue); //DateTime dt = DateTime.Now; int year = 0; if (年份.SelectedText == "" || 年份.SelectedText == null) { DateTime dt = DateTime.Now; year = dt.Year; } else { year = int.Parse(年份.SelectedText); } GridGZ.RecordCount = gzbll.查询设备故障总数(ID, ttbSearch.Text, year); GridGZ.DataSource = gzbll.各单位查询设备故障(ID, "", year, GridGZ.PageIndex, GridGZ.PageSize - 1); // 3.绑定到Grid //GridGZ.DataSource = table; GridGZ.DataBind(); }