private void frmWLFluxMap_Load(object sender, EventArgs e) { this.Text = Strings.WLFluxMap; DataTable tbl = DBI.GetDBI().GetWLFluxMapDataTable(); this.dataGridView1.DataSource = tbl; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnQuery_Click(object sender, EventArgs e) { DataTable tbl = DBI.GetDBI().Query(this.BeginDT, this.EndDT); this.dataGridView1.DataSource = tbl; // calc during amount // if (tbl.Rows.Count <= 1) { this.lblDuringAmount.Text = string.Empty; } else { DataRow firstRow = tbl.Select("时间 = min(时间)")[0]; DataRow lastRow = tbl.Select("时间 = max(时间)")[0]; DateTime firstDT = Convert.ToDateTime(firstRow["时间"]); DateTime lastDT = Convert.ToDateTime(lastRow["时间"]); double first = Convert.ToDouble(firstRow["累计流量(m3)"]); double last = Convert.ToDouble(lastRow["累计流量(m3)"]); double duringAmount = last - first; string s = string.Format("阶段时间: {0} ~ {1}" + Environment.NewLine + Environment.NewLine + "阶段水量: {2} (m3)", firstDT, lastDT, duringAmount); this.lblDuringAmount.Text = s; } }