private void StartLoadDtus() { string sql = @"select t.终端登录号码,t.pumpName from( select a.终端登录号码,c.PName pumpName ,ROW_NUMBER() over( partition by c.PName order by c.PName asc ) r from DTUBase a,PumpJZ b,pump c where a.是否使用=1 and b.DTUCode=a.终端登录号码 and b.PumpId=c.ID and b.PumpJZReadMode='DTU') t where t.r=1;"; DataTable dt = DBUtil.ExecuteDataTable(sql, out string err); if (!string.IsNullOrEmpty(err)) { ShowErrMessBox(err); return; } List <LoginInfo> dtuIDs = new List <LoginInfo>(); foreach (DataRow dr in dt.Rows) { LoginInfo dtu = new LoginInfo() { DTUID = DataUtil.ToString(dr["终端登录号码"]), PumpName = DataUtil.ToString(dr["pumpName"]) }; dtuIDs.Add(dtu); } RenderDtuCombox(dtuIDs.ToArray()); }
private void LoadCommandsDetail() { this.dataGridView_commands.Rows.Clear(); string sql = string.Format(@" select ts.ID,ts.type as '类型' ,ts.sensorID,ts.sensorValue,ts.status as '任务状态', CONVERT(varchar(100),ts.BeginTime, 120) as 开始时间, CONVERT(varchar(100),ts.EndTime, 120) as 结束时间,ts.耗时,ts.Mess as 备注 from PandaCommand ts where sensorID in ( select ss.ID from Sensor ss where ss.StationID in( select t.StationID from PandaDTU t where t.终端登录号码='{0}'))", this.textTel.Text.Trim()); DataTable dt = DBUtil.ExecuteDataTable(sql, out string errMsg); if (!string.IsNullOrEmpty(errMsg)) { ShowMessageAndAddLog(errMsg); return; } foreach (DataRow dr in dt.Rows) { DataGridViewRow row = new DataGridViewRow(); switch (dr["任务状态"].ToString()) { case "任务成功": row.DefaultCellStyle.BackColor = Color.LightGreen; break; case "任务失败": case "任务超时": row.DefaultCellStyle.BackColor = Color.Red; break; } int index = dataGridView_commands.Rows.Add(row); dataGridView_commands.Rows[index].Cells[0].Value = dr["ID"].ToString(); dataGridView_commands.Rows[index].Cells[1].Value = dr["类型"].ToString(); dataGridView_commands.Rows[index].Cells[2].Value = dr["sensorID"].ToString(); dataGridView_commands.Rows[index].Cells[3].Value = dr["sensorValue"].ToString(); dataGridView_commands.Rows[index].Cells[4].Value = dr["任务状态"].ToString(); dataGridView_commands.Rows[index].Cells[5].Value = dr["开始时间"].ToString(); dataGridView_commands.Rows[index].Cells[6].Value = dr["结束时间"].ToString(); dataGridView_commands.Rows[index].Cells[7].Value = dr["耗时"].ToString(); dataGridView_commands.Rows[index].Cells[8].Value = dr["备注"].ToString(); } }