/// <summary> /// 绑定结果列表 /// </summary> private void BindResult(NoiseRecorder rec) { DataTable dt = new DataTable(); dt.Columns.Add("记录仪编号"); dt.Columns.Add("幅度"); dt.Columns.Add("频率"); dt.Columns.Add("读取时间"); dt.Columns.Add("漏水状态"); dt.Columns.Add("漏水概率"); if (rec.Result != null) { NoiseResult re = rec.Result; string str = "不漏水"; if (re.IsLeak == 0) { str = "不漏水"; } else if (re.IsLeak == 1) { str = "漏水"; } dt.Rows.Add(new object[] { rec.ID, re.LeakAmplitude.ToString(), re.LeakFrequency.ToString(), re.ReadTime.ToString("yyyy-MM-dd HH:mm:ss"), str, (re.LeakProbability * 100).ToString("f1") + "%" }); } // 绑定数据 MethodInvoker mi = (new MethodInvoker(() => { gridControlResult.DataSource = dt; })); this.Invoke(mi); }
private void gridViewResultList_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) { if (e.Column.Caption == "记录仪编号") { int tempId = Convert.ToInt32(e.CellValue); NoiseResult temp = (from item in GlobalValue.recorderList where item.ID == tempId select item).ToList()[0].Result; isLeak = temp.IsLeak; } else if (e.Column.Caption == "幅度") { e.Appearance.BackColor = Color.DodgerBlue; } else if (e.Column.Caption == "频率") { e.Appearance.BackColor = Color.MediumSeaGreen; } else if (e.Column.Caption == "漏水状态") { if (isLeak == 0) { e.DisplayText = "不漏水"; e.Appearance.BackColor = Color.SpringGreen; } else { e.DisplayText = "漏水"; e.Appearance.BackColor = Color.Red; } } }
/// <summary> /// 添加噪声分析结果到数据库 /// </summary> /// <param name="result">噪声分析结果对象</param> public static int AddNoiseResult(NoiseResult result) { try { string sql = string.Empty; int query = 0; sql = string.Format(@"INSERT INTO DL_NoiseAnalyse(GroupId, RecorderId, MinLeakValue, MinFrequencyValue, UnloadTime, IsLeak, ESA, HistoryFlag, CollTime, EnergyValue, LeakProbability) VALUES({0},{1},{2},{3},'{4}',{5},{6},{7},'{8}',{9}, {10})", result.GroupID, result.RecorderID, result.LeakAmplitude, result.LeakFrequency, result.UploadTime.ToString("yyyy/MM/dd HH:mm:ss").Replace('-', '/'), result.IsLeak.ToString(), result.ESA, result.UploadFlag, result.ReadTime.ToString("yyyy/MM/dd HH:mm:ss").Replace('-', '/'), result.EnergyValue.ToString("f4"), result.LeakProbability.ToString("f4")); query = SQLHelper.ExecuteNonQuery(sql); return(query); } catch (Exception ex) { throw ex; //return -1; } }
/// <summary> /// 绑定结果列表 /// </summary> private void BindResult(NoiseRecorderGroup gp) { gridControlResult.DataSource = null; DataTable dt = new DataTable(); ; dt.Columns.Add("记录仪编号"); dt.Columns.Add("幅度"); dt.Columns.Add("频率"); dt.Columns.Add("读取时间"); dt.Columns.Add("漏水状态"); dt.Columns.Add("漏水概率"); for (int i = 0; i < gp.RecorderList.Count; i++) { if (gp.RecorderList[i].Result != null) { NoiseResult re = gp.RecorderList[i].Result; string str = "不漏水"; if (re.IsLeak == 0) { str = "不漏水"; } else if (re.IsLeak == 1) { str = "漏水"; } dt.Rows.Add(new object[] { GlobalValue.recorderList[i].ID, re.LeakAmplitude.ToString(), re.LeakFrequency.ToString(), re.ReadTime.ToString("yyyy-MM-dd HH:mm:ss"), str, (re.LeakProbability * 100).ToString("f1") + "%" }); } } // 绑定数据 MethodInvoker mi = (new MethodInvoker(() => { gridControlResult.DataSource = dt; })); this.Invoke(mi); }