private void btnQuery_Click(object sender, System.EventArgs e) { Session.Remove("QUERY"); string strQueryType = this.ddlQueryType.SelectedValue; if (strQueryType == "1") { if (this.ddlProviderName.SelectedValue == "全部") { this.Popup("请指定要统计的供应商!"); return; } } string strProviderName = this.ddlProviderName.SelectedValue; if (strProviderName == "全部") { strProviderName = ""; } string strMaterialType = this.ddlMaterialType.SelectedValue; if (strMaterialType == "全部") { strMaterialType = ""; } Hashtable htpara = new Hashtable(); htpara.Add("strMonth", this.ddlMonth.SelectedValue); htpara.Add("strProviderName", strProviderName); htpara.Add("strMaterialType", strMaterialType); htpara.Add("strMaterialName", this.txtMaterialName.Text.Trim()); Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; msb1 = new MaterialSBusi(strcons); try { DataSet dsout = msb1.GetMaterialsEnterReport(strQueryType, htpara); DataTable dtout = dsout.Tables["QueryResult"]; if (dtout == null) { this.SetErrorMsgPageBydir("查询出错,请重试!"); btnExcel.Enabled = false; return; } else { txtRecordCount.Text = dsout.Tables["SumState"].Rows[0]["RecordCount"].ToString(); txtToltalCount.Text = dsout.Tables["SumState"].Rows[0]["TotalCount"].ToString(); txtTotalFee.Text = dsout.Tables["SumState"].Rows[0]["TotalFee"].ToString(); dtout.TableName = "原材料资料清单"; if (strQueryType == "0") { 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; } }