private void btnQuery_Click(object sender, System.EventArgs e) { strBeginDate = Request.Form["txtBegin"].ToString(); strEndDate = Request.Form["txtEnd"].ToString(); if (strBeginDate == "" || strEndDate == "" || strBeginDate == null || strEndDate == null) { this.SetErrorMsgPageBydir("时间不能为空,请重新选择时间!"); return; } Session.Remove("QUERY"); Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; msb1 = new MaterialSBusi(strcons); try { DataTable dtout = msb1.GetMaterialsEnterOutModList(this.ddlEnterOutType.SelectedValue, strBeginDate, strEndDate); if (dtout == null) { this.SetErrorMsgPageBydir("查询出错,请重试!"); btnExcel.Enabled = false; return; } else { dtout.TableName = "原材料入出库修正报表"; this.TableConvert(dtout, "原材料类型", "tbNameCodeToStorage", "vcCommSign='MaterialType'"); this.TableConvert(dtout, "操作类型", "tbNameCodeToStorage", "vcCommSign='MaEnterOutType'"); this.TableConvert(dtout, "部门", "NewDept"); DataTable dtexcel = dtout.Copy(); Session["QUERY"] = dtout; // for(int i=0;i<dtexcel.Rows.Count;i++) // { // dtexcel.Rows[i][0]="'"+dtexcel.Rows[i][0].ToString(); // } Session["toExcel"] = dtexcel; if (dtout.Rows.Count <= 0) { btnExcel.Enabled = false; } else { btnExcel.Enabled = true; } } UcPageView1.MyDataGrid.PageSize = 30; DataView dvOut = new DataView(dtout); this.UcPageView1.MyDataSource = dvOut; this.UcPageView1.BindGrid(); } catch (Exception er) { this.clog.WriteLine(er); this.SetErrorMsgPageBydir("查询错误,请重试!"); return; } }