日期:2014-05-18 浏览次数:20849 次
private void Index_Load(object sender, EventArgs e) { Thread thread = new Thread(new ThreadStart(RunsOnWorkerThread)); thread.Start(); } //委托 private void RunsOnWorkerThread() { MethodInvoker mi = new MethodInvoker(dataSet1); BeginInvoke(mi); } //设备提醒 void dataSet1() { if (AppRun) { dataGridView1.Rows.Clear(); string sql = " select tw.*,b.gprs_number from dbo.Temp_WaterState as tw join basis_use_water_origin_rtu as b on tw.T_ClientID=b.clientid"; DataSet dt = DHelper.GetDataSet(sql);//帮助类 int cot = dt.Tables[0].Rows.Count; dataGridView1.Rows.Add(cot); for (int i = 0; i < cot; i++) { // DefaultCellStyle.BackColor = Color.Red; dataGridView1.Rows[i].Cells["rtu"].Value = dt.Tables[0].Rows[i]["T_ClientID"] + ""; dataGridView1.Rows[i].Cells["jcd"].Value = DHelper.getName(dt.Tables[0].Rows[i]["T_ClientID"] + ""); dataGridView1.Rows[i].Cells["gxsj"].Value = dt.Tables[0].Rows[i]["T_Time"] + ""; dataGridView1.Rows[i].Cells["ydkh"].Value = dt.Tables[0].Rows[i]["gprs_number"] + ""; int kzq = Convert.ToInt32(dt.Tables[0].Rows[i]["T_EquipState"]); if (kzq == 0) { dataGridView1.Rows[i].Cells["kzq"].Style.BackColor = Color.Red; } dataGridView1.Rows[i].Cells["kzq"].Value = DHelper.getKZQ(kzq);// 状态。 正常还是中断 int wl = Convert.ToInt32(dt.Tables[0].Rows[i]["T_GPRSState"]); if (wl == 0) { dataGridView1.Rows[i].Cells["wl"].Style.BackColor = Color.Red; } dataGridView1.Rows[i].Cells["wl"].Value = DHelper.getWL(wl); int gd = Convert.ToInt32(dt.Tables[0].Rows[i]["T_PowerSupply"]); if (gd != 1) { dataGridView1.Rows[i].Cells["gd"].Style.BackColor = Color.Red; } dataGridView1.Rows[i].Cells["gd"].Value = DHelper.getGD(gd); int kzg = Convert.ToInt32(dt.Tables[0].Rows[i]["T_OpenAlarm"]); if (kzg == 0) { dataGridView1.Rows[i].Cells["kzg"].Style.BackColor = Color.Red; } dataGridView1.Rows[i].Cells["kzg"].Value = DHelper.getM(kzg); } Thread.Sleep(5000); } }