// 设置查询条件 public bool SetFilter(string iStationId, DateTime timeStart, DateTime timeEnd) { ClearAllState(); m_strStaionId = iStationId; m_dateTimeStart = timeStart; m_dateTimeEnd = timeEnd; List <CEntitySoilData> listData = m_proxySoilData.QueryByStationAndTime(iStationId, timeStart, timeEnd); this.SetSoilData(listData); m_iTotalRowCount = listData.Count; m_iTotalPage = 1; // 没有换页 return(true); }
//this.Series.Clear(); //Series dataTable1Series = new Series("电压值"); //Series dataTable2Series = new Series("10CM含水率"); //Series dataTable3Series = new Series("20CM含水率"); //Series dataTable4Series = new Series("40CM含水率"); //dataTable1Series.Points.DataBind(dataTable1.AsEnumerable(), CS_Asix_DateTime, CS_Serial_Name_Votage, ""); //dataTable1Series.XValueType = ChartValueType.DateTime;//设置X轴类型为时间 //dataTable1Series.ChartType = SeriesChartType.Line; //设置Y轴为折线 //dataTable2Series.Points.DataBind(dataTable2.AsEnumerable(), CS_Asix_DateTime, CS_Serial_Name_M10, ""); //dataTable2Series.XValueType = ChartValueType.DateTime;//设置X轴类型为时间 //dataTable2Series.ChartType = SeriesChartType.Line; //设置Y轴为折线 //this.Series.Add(dataTable1Series); // this.Series.Add(dataTable2Series); public bool SetFilter(string iStationId, DateTime timeStart, DateTime timeEnd) { m_annotation.Visible = false; ClearAllDatas(); List <CEntitySoilData> listDatas = m_proxySoilData.QueryByStationAndTime(iStationId, timeStart, timeEnd); int rowcount = listDatas.Count; if (rowcount > CI_Chart_Max_Count) { // 数据量太大,退出绘图 MessageBox.Show("查询结果集太大,自动退出绘图"); return(false); } AddSoilData(listDatas); //显示图形 return(true); }
//11.12 private void EH_MI_ExportToExcel_Click(object sender, EventArgs e) { // 弹出对话框,并导出到Excel文件 SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "Excel文件(*.xls)|*.xls|所有文件(*.*)|*.*"; if (DialogResult.OK == dlg.ShowDialog()) { // 保存到Excel表格中 DataTable dataTable = new DataTable(); // dataTable.Columns.Add(CS_VoltageID, typeof(Int64)); dataTable.Columns.Add(CS_StationID); dataTable.Columns.Add(CS_StationName, typeof(string)); dataTable.Columns.Add(CS_TimeCollected, typeof(DateTime)); dataTable.Columns.Add(CS_Voltage, typeof(string)); dataTable.Columns.Add(CS_V10, typeof(string)); dataTable.Columns.Add(CS_M10, typeof(string)); dataTable.Columns.Add(CS_V20, typeof(string)); dataTable.Columns.Add(CS_M20, typeof(string)); dataTable.Columns.Add(CS_V30, typeof(string)); dataTable.Columns.Add(CS_M30, typeof(string)); dataTable.Columns.Add(CS_V40, typeof(string)); dataTable.Columns.Add(CS_M40, typeof(string)); dataTable.Columns.Add(CS_V60, typeof(string)); dataTable.Columns.Add(CS_M60, typeof(string)); dataTable.Columns.Add(CS_ReciveTime, typeof(DateTime)); dataTable.Columns.Add(CS_MsgType, typeof(string)); dataTable.Columns.Add(CS_ChannelType, typeof(string)); // 逐页读取数据 for (int i = 0; i < m_iTotalPage; ++i) { List <CEntitySoilData> tmpListData = m_proxySoilData.QueryByStationAndTime(m_strStaionId, m_dateTimeStart, m_dateTimeEnd); foreach (CEntitySoilData soilData in tmpListData) { // 赋值到dataTable中去 DataRow row = dataTable.NewRow(); // row[CS_VoltageID] = voltage.VoltageID; row[CS_StationID] = soilData.StationID; row[CS_StationName] = CDBSoilDataMgr.Instance.GetSoilStationInfoByStationId(soilData.StationID).StationName; row[CS_TimeCollected] = soilData.DataTime; row[CS_Voltage] = soilData.DVoltage; row[CS_V10] = soilData.Voltage10; row[CS_M10] = soilData.Voltage10; row[CS_V20] = soilData.Voltage20; row[CS_M20] = soilData.Voltage20; row[CS_V40] = soilData.Voltage40; row[CS_M40] = soilData.Voltage40; row[CS_V60] = soilData.Voltage60; row[CS_M60] = soilData.Voltage60; row[CS_ReciveTime] = soilData.reciveTime; row[CS_MsgType] = CEnumHelper.MessageTypeToUIStr(soilData.MessageType); row[CS_ChannelType] = CEnumHelper.ChannelTypeToUIStr(soilData.ChannelType); dataTable.Rows.Add(row); } } // 显示提示框 CMessageBox box = new CMessageBox() { MessageInfo = "正在导出表格,请稍候" }; box.ShowDialog(this); if (CExcelExport.ExportToExcelWrapper(dataTable, dlg.FileName, "电压表")) { //box.Invoke((Action)delegate { box.Close(); }); box.CloseDialog(); MessageBox.Show(string.Format("导出成功,保存在文件\"{0}\"中", dlg.FileName)); } else { //box.Invoke((Action)delegate { box.Close(); }); box.CloseDialog(); MessageBox.Show("导出失败"); } }//end of if dialog okay }