diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 描述/端口 - Label colDevPort = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "描述", - Location = new Point(242, 0), - Size = new Size(50, 50) - }; - dataGridView_CounterResult.Controls.Add(colDevPort); - colDevPort.BringToFront(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px dataGridView_CounterResult.Columns[0].Width = 50; - dataGridView_CounterResult.Columns[1].Width = 95; - dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[3].Width = 50; - dataGridView_CounterResult.Columns[4].Width = 85; - dataGridView_CounterResult.Columns[5].Width = 105; - dataGridView_CounterResult.Columns[6].Width = 85; - dataGridView_CounterResult.Columns[7].Width = 129; + dataGridView_CounterResult.Columns[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 描述/端口 - Label colDevPort = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "描述", - Location = new Point(242, 0), - Size = new Size(50, 50) - }; - dataGridView_CounterResult.Controls.Add(colDevPort); - colDevPort.BringToFront(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px dataGridView_CounterResult.Columns[0].Width = 50; - dataGridView_CounterResult.Columns[1].Width = 95; - dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[3].Width = 50; - dataGridView_CounterResult.Columns[4].Width = 85; - dataGridView_CounterResult.Columns[5].Width = 105; - dataGridView_CounterResult.Columns[6].Width = 85; - dataGridView_CounterResult.Columns[7].Width = 129; + dataGridView_CounterResult.Columns[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index 09d1e4a..5fd129f 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -31,6 +31,9 @@ { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -73,7 +76,8 @@ this.pic_stability_1 = new System.Windows.Forms.PictureBox(); this.pic_accuracy_1 = new System.Windows.Forms.PictureBox(); this.pic_bootFeature_1 = new System.Windows.Forms.PictureBox(); - this.dataGridView_Channel = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel_old = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel = new Casic.Birmm.RbFreqStandMeasure.MyDataGridView(); this.panel_toTestDev.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tableToBeTested)).BeginInit(); this.panelBase.SuspendLayout(); @@ -103,6 +107,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).BeginInit(); this.SuspendLayout(); // @@ -299,6 +304,7 @@ this.panel_channelList.Controls.Add(this.panel2); this.panel_channelList.Controls.Add(this.panel1); this.panel_channelList.Controls.Add(this.dataGridView_Channel); + this.panel_channelList.Controls.Add(this.dataGridView_Channel_old); this.panel_channelList.Location = new System.Drawing.Point(11, 227); this.panel_channelList.Name = "panel_channelList"; this.panel_channelList.Size = new System.Drawing.Size(1004, 420); @@ -569,6 +575,56 @@ this.pic_bootFeature_1.TabIndex = 319; this.pic_bootFeature_1.TabStop = false; // + // dataGridView_Channel_old + // + this.dataGridView_Channel_old.AllowUserToAddRows = false; + this.dataGridView_Channel_old.AllowUserToDeleteRows = false; + this.dataGridView_Channel_old.AllowUserToResizeColumns = false; + this.dataGridView_Channel_old.AllowUserToResizeRows = false; + dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6; + this.dataGridView_Channel_old.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView_Channel_old.BackgroundColor = System.Drawing.Color.White; + this.dataGridView_Channel_old.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dataGridView_Channel_old.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SunkenHorizontal; + this.dataGridView_Channel_old.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable; + this.dataGridView_Channel_old.ColumnHeadersHeight = 30; + this.dataGridView_Channel_old.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Channel_old.DefaultCellStyle = dataGridViewCellStyle7; + this.dataGridView_Channel_old.GridColor = System.Drawing.Color.DarkGray; + this.dataGridView_Channel_old.Location = new System.Drawing.Point(11, 10); + this.dataGridView_Channel_old.Margin = new System.Windows.Forms.Padding(0); + this.dataGridView_Channel_old.MultiSelect = false; + this.dataGridView_Channel_old.Name = "dataGridView_Channel_old"; + this.dataGridView_Channel_old.RowHeadersVisible = false; + this.dataGridView_Channel_old.RowHeadersWidth = 30; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.RowsDefaultCellStyle = dataGridViewCellStyle8; + this.dataGridView_Channel_old.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.Transparent; + this.dataGridView_Channel_old.RowTemplate.Height = 74; + this.dataGridView_Channel_old.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.dataGridView_Channel_old.Size = new System.Drawing.Size(984, 400); + this.dataGridView_Channel_old.TabIndex = 0; + this.dataGridView_Channel_old.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); + this.dataGridView_Channel_old.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + // // dataGridView_Channel // this.dataGridView_Channel.AllowUserToAddRows = false; @@ -577,7 +633,7 @@ this.dataGridView_Channel.AllowUserToResizeRows = false; dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -606,7 +662,7 @@ this.dataGridView_Channel.RowHeadersWidth = 30; dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -615,9 +671,9 @@ this.dataGridView_Channel.RowTemplate.Height = 74; this.dataGridView_Channel.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dataGridView_Channel.Size = new System.Drawing.Size(984, 400); - this.dataGridView_Channel.TabIndex = 0; - this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); - this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + this.dataGridView_Channel.TabIndex = 342; + this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick_1); + this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint_1); // // HomeCtrlForm // @@ -661,6 +717,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).EndInit(); this.ResumeLayout(false); @@ -679,7 +736,7 @@ private System.Windows.Forms.Button btnPre; private System.Windows.Forms.TextBox textBoxPage; private System.Windows.Forms.Button btnNext; - private System.Windows.Forms.DataGridView dataGridView_Channel; + private System.Windows.Forms.DataGridView dataGridView_Channel_old; private System.Windows.Forms.Label labelNodata; private System.Windows.Forms.PictureBox pic_accuracy_1; private System.Windows.Forms.PictureBox pic_ageRate_1; @@ -708,5 +765,6 @@ private System.Windows.Forms.Panel panel3; public System.Windows.Forms.Label label_receiverStatus; public System.Windows.Forms.Label label_clockStatus; + private MyDataGridView dataGridView_Channel; } } diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 描述/端口 - Label colDevPort = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "描述", - Location = new Point(242, 0), - Size = new Size(50, 50) - }; - dataGridView_CounterResult.Controls.Add(colDevPort); - colDevPort.BringToFront(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px dataGridView_CounterResult.Columns[0].Width = 50; - dataGridView_CounterResult.Columns[1].Width = 95; - dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[3].Width = 50; - dataGridView_CounterResult.Columns[4].Width = 85; - dataGridView_CounterResult.Columns[5].Width = 105; - dataGridView_CounterResult.Columns[6].Width = 85; - dataGridView_CounterResult.Columns[7].Width = 129; + dataGridView_CounterResult.Columns[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index 09d1e4a..5fd129f 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -31,6 +31,9 @@ { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -73,7 +76,8 @@ this.pic_stability_1 = new System.Windows.Forms.PictureBox(); this.pic_accuracy_1 = new System.Windows.Forms.PictureBox(); this.pic_bootFeature_1 = new System.Windows.Forms.PictureBox(); - this.dataGridView_Channel = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel_old = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel = new Casic.Birmm.RbFreqStandMeasure.MyDataGridView(); this.panel_toTestDev.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tableToBeTested)).BeginInit(); this.panelBase.SuspendLayout(); @@ -103,6 +107,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).BeginInit(); this.SuspendLayout(); // @@ -299,6 +304,7 @@ this.panel_channelList.Controls.Add(this.panel2); this.panel_channelList.Controls.Add(this.panel1); this.panel_channelList.Controls.Add(this.dataGridView_Channel); + this.panel_channelList.Controls.Add(this.dataGridView_Channel_old); this.panel_channelList.Location = new System.Drawing.Point(11, 227); this.panel_channelList.Name = "panel_channelList"; this.panel_channelList.Size = new System.Drawing.Size(1004, 420); @@ -569,6 +575,56 @@ this.pic_bootFeature_1.TabIndex = 319; this.pic_bootFeature_1.TabStop = false; // + // dataGridView_Channel_old + // + this.dataGridView_Channel_old.AllowUserToAddRows = false; + this.dataGridView_Channel_old.AllowUserToDeleteRows = false; + this.dataGridView_Channel_old.AllowUserToResizeColumns = false; + this.dataGridView_Channel_old.AllowUserToResizeRows = false; + dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6; + this.dataGridView_Channel_old.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView_Channel_old.BackgroundColor = System.Drawing.Color.White; + this.dataGridView_Channel_old.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dataGridView_Channel_old.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SunkenHorizontal; + this.dataGridView_Channel_old.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable; + this.dataGridView_Channel_old.ColumnHeadersHeight = 30; + this.dataGridView_Channel_old.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Channel_old.DefaultCellStyle = dataGridViewCellStyle7; + this.dataGridView_Channel_old.GridColor = System.Drawing.Color.DarkGray; + this.dataGridView_Channel_old.Location = new System.Drawing.Point(11, 10); + this.dataGridView_Channel_old.Margin = new System.Windows.Forms.Padding(0); + this.dataGridView_Channel_old.MultiSelect = false; + this.dataGridView_Channel_old.Name = "dataGridView_Channel_old"; + this.dataGridView_Channel_old.RowHeadersVisible = false; + this.dataGridView_Channel_old.RowHeadersWidth = 30; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.RowsDefaultCellStyle = dataGridViewCellStyle8; + this.dataGridView_Channel_old.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.Transparent; + this.dataGridView_Channel_old.RowTemplate.Height = 74; + this.dataGridView_Channel_old.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.dataGridView_Channel_old.Size = new System.Drawing.Size(984, 400); + this.dataGridView_Channel_old.TabIndex = 0; + this.dataGridView_Channel_old.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); + this.dataGridView_Channel_old.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + // // dataGridView_Channel // this.dataGridView_Channel.AllowUserToAddRows = false; @@ -577,7 +633,7 @@ this.dataGridView_Channel.AllowUserToResizeRows = false; dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -606,7 +662,7 @@ this.dataGridView_Channel.RowHeadersWidth = 30; dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -615,9 +671,9 @@ this.dataGridView_Channel.RowTemplate.Height = 74; this.dataGridView_Channel.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dataGridView_Channel.Size = new System.Drawing.Size(984, 400); - this.dataGridView_Channel.TabIndex = 0; - this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); - this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + this.dataGridView_Channel.TabIndex = 342; + this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick_1); + this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint_1); // // HomeCtrlForm // @@ -661,6 +717,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).EndInit(); this.ResumeLayout(false); @@ -679,7 +736,7 @@ private System.Windows.Forms.Button btnPre; private System.Windows.Forms.TextBox textBoxPage; private System.Windows.Forms.Button btnNext; - private System.Windows.Forms.DataGridView dataGridView_Channel; + private System.Windows.Forms.DataGridView dataGridView_Channel_old; private System.Windows.Forms.Label labelNodata; private System.Windows.Forms.PictureBox pic_accuracy_1; private System.Windows.Forms.PictureBox pic_ageRate_1; @@ -708,5 +765,6 @@ private System.Windows.Forms.Panel panel3; public System.Windows.Forms.Label label_receiverStatus; public System.Windows.Forms.Label label_clockStatus; + private MyDataGridView dataGridView_Channel; } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index ca3181d..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,335 +305,354 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + lock (obj) { - channelFreeList.Remove(device.Channel); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } + } } - } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { try { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); - channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else - { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); - } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[12].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; } catch (Exception ex) { @@ -646,23 +665,41 @@ { try { - dataGridView_Channel.ClearSelection(); + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - } - else - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + dataGridView_Channel.ClearSelection(); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); + int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); + if (channelFreeList.Contains(channelNo + "")) + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -729,26 +766,50 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else @@ -773,7 +834,51 @@ channelDlg.ShowDialog(); } - - + private void dataGridView_Channel_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) + { + cellDoubleClick(e.RowIndex); + } + + private void dataGridView_Channel_RowPostPaint_1(object sender, DataGridViewRowPostPaintEventArgs e) + { + try + { + lock (obj) + { + dataGridView_Channel.ClearSelection(); + + int channelNo = e.RowIndex + 1; + + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + + } + } } } diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 描述/端口 - Label colDevPort = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "描述", - Location = new Point(242, 0), - Size = new Size(50, 50) - }; - dataGridView_CounterResult.Controls.Add(colDevPort); - colDevPort.BringToFront(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px dataGridView_CounterResult.Columns[0].Width = 50; - dataGridView_CounterResult.Columns[1].Width = 95; - dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[3].Width = 50; - dataGridView_CounterResult.Columns[4].Width = 85; - dataGridView_CounterResult.Columns[5].Width = 105; - dataGridView_CounterResult.Columns[6].Width = 85; - dataGridView_CounterResult.Columns[7].Width = 129; + dataGridView_CounterResult.Columns[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index 09d1e4a..5fd129f 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -31,6 +31,9 @@ { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -73,7 +76,8 @@ this.pic_stability_1 = new System.Windows.Forms.PictureBox(); this.pic_accuracy_1 = new System.Windows.Forms.PictureBox(); this.pic_bootFeature_1 = new System.Windows.Forms.PictureBox(); - this.dataGridView_Channel = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel_old = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel = new Casic.Birmm.RbFreqStandMeasure.MyDataGridView(); this.panel_toTestDev.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tableToBeTested)).BeginInit(); this.panelBase.SuspendLayout(); @@ -103,6 +107,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).BeginInit(); this.SuspendLayout(); // @@ -299,6 +304,7 @@ this.panel_channelList.Controls.Add(this.panel2); this.panel_channelList.Controls.Add(this.panel1); this.panel_channelList.Controls.Add(this.dataGridView_Channel); + this.panel_channelList.Controls.Add(this.dataGridView_Channel_old); this.panel_channelList.Location = new System.Drawing.Point(11, 227); this.panel_channelList.Name = "panel_channelList"; this.panel_channelList.Size = new System.Drawing.Size(1004, 420); @@ -569,6 +575,56 @@ this.pic_bootFeature_1.TabIndex = 319; this.pic_bootFeature_1.TabStop = false; // + // dataGridView_Channel_old + // + this.dataGridView_Channel_old.AllowUserToAddRows = false; + this.dataGridView_Channel_old.AllowUserToDeleteRows = false; + this.dataGridView_Channel_old.AllowUserToResizeColumns = false; + this.dataGridView_Channel_old.AllowUserToResizeRows = false; + dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6; + this.dataGridView_Channel_old.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView_Channel_old.BackgroundColor = System.Drawing.Color.White; + this.dataGridView_Channel_old.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dataGridView_Channel_old.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SunkenHorizontal; + this.dataGridView_Channel_old.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable; + this.dataGridView_Channel_old.ColumnHeadersHeight = 30; + this.dataGridView_Channel_old.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Channel_old.DefaultCellStyle = dataGridViewCellStyle7; + this.dataGridView_Channel_old.GridColor = System.Drawing.Color.DarkGray; + this.dataGridView_Channel_old.Location = new System.Drawing.Point(11, 10); + this.dataGridView_Channel_old.Margin = new System.Windows.Forms.Padding(0); + this.dataGridView_Channel_old.MultiSelect = false; + this.dataGridView_Channel_old.Name = "dataGridView_Channel_old"; + this.dataGridView_Channel_old.RowHeadersVisible = false; + this.dataGridView_Channel_old.RowHeadersWidth = 30; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.RowsDefaultCellStyle = dataGridViewCellStyle8; + this.dataGridView_Channel_old.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.Transparent; + this.dataGridView_Channel_old.RowTemplate.Height = 74; + this.dataGridView_Channel_old.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.dataGridView_Channel_old.Size = new System.Drawing.Size(984, 400); + this.dataGridView_Channel_old.TabIndex = 0; + this.dataGridView_Channel_old.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); + this.dataGridView_Channel_old.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + // // dataGridView_Channel // this.dataGridView_Channel.AllowUserToAddRows = false; @@ -577,7 +633,7 @@ this.dataGridView_Channel.AllowUserToResizeRows = false; dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -606,7 +662,7 @@ this.dataGridView_Channel.RowHeadersWidth = 30; dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -615,9 +671,9 @@ this.dataGridView_Channel.RowTemplate.Height = 74; this.dataGridView_Channel.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dataGridView_Channel.Size = new System.Drawing.Size(984, 400); - this.dataGridView_Channel.TabIndex = 0; - this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); - this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + this.dataGridView_Channel.TabIndex = 342; + this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick_1); + this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint_1); // // HomeCtrlForm // @@ -661,6 +717,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).EndInit(); this.ResumeLayout(false); @@ -679,7 +736,7 @@ private System.Windows.Forms.Button btnPre; private System.Windows.Forms.TextBox textBoxPage; private System.Windows.Forms.Button btnNext; - private System.Windows.Forms.DataGridView dataGridView_Channel; + private System.Windows.Forms.DataGridView dataGridView_Channel_old; private System.Windows.Forms.Label labelNodata; private System.Windows.Forms.PictureBox pic_accuracy_1; private System.Windows.Forms.PictureBox pic_ageRate_1; @@ -708,5 +765,6 @@ private System.Windows.Forms.Panel panel3; public System.Windows.Forms.Label label_receiverStatus; public System.Windows.Forms.Label label_clockStatus; + private MyDataGridView dataGridView_Channel; } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index ca3181d..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,335 +305,354 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + lock (obj) { - channelFreeList.Remove(device.Channel); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } + } } - } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { try { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); - channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else - { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); - } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[12].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; } catch (Exception ex) { @@ -646,23 +665,41 @@ { try { - dataGridView_Channel.ClearSelection(); + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - } - else - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + dataGridView_Channel.ClearSelection(); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); + int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); + if (channelFreeList.Contains(channelNo + "")) + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -729,26 +766,50 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else @@ -773,7 +834,51 @@ channelDlg.ShowDialog(); } - - + private void dataGridView_Channel_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) + { + cellDoubleClick(e.RowIndex); + } + + private void dataGridView_Channel_RowPostPaint_1(object sender, DataGridViewRowPostPaintEventArgs e) + { + try + { + lock (obj) + { + dataGridView_Channel.ClearSelection(); + + int channelNo = e.RowIndex + 1; + + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + + } + } } } diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index f99f106..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -47,6 +47,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); int channel = 0; + public Action HideMaskAction { @@ -66,9 +67,7 @@ SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 - CheckForIllegalCrossThreadCalls = false; - - + CheckForIllegalCrossThreadCalls = false; } private void btnExitChannel_Click(object sender, EventArgs e) @@ -158,6 +157,10 @@ MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -165,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 描述/端口 - Label colDevPort = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "描述", - Location = new Point(242, 0), - Size = new Size(50, 50) - }; - dataGridView_CounterResult.Controls.Add(colDevPort); - colDevPort.BringToFront(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px dataGridView_CounterResult.Columns[0].Width = 50; - dataGridView_CounterResult.Columns[1].Width = 95; - dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[3].Width = 50; - dataGridView_CounterResult.Columns[4].Width = 85; - dataGridView_CounterResult.Columns[5].Width = 105; - dataGridView_CounterResult.Columns[6].Width = 85; - dataGridView_CounterResult.Columns[7].Width = 129; + dataGridView_CounterResult.Columns[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index 09d1e4a..5fd129f 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -31,6 +31,9 @@ { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -73,7 +76,8 @@ this.pic_stability_1 = new System.Windows.Forms.PictureBox(); this.pic_accuracy_1 = new System.Windows.Forms.PictureBox(); this.pic_bootFeature_1 = new System.Windows.Forms.PictureBox(); - this.dataGridView_Channel = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel_old = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel = new Casic.Birmm.RbFreqStandMeasure.MyDataGridView(); this.panel_toTestDev.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tableToBeTested)).BeginInit(); this.panelBase.SuspendLayout(); @@ -103,6 +107,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).BeginInit(); this.SuspendLayout(); // @@ -299,6 +304,7 @@ this.panel_channelList.Controls.Add(this.panel2); this.panel_channelList.Controls.Add(this.panel1); this.panel_channelList.Controls.Add(this.dataGridView_Channel); + this.panel_channelList.Controls.Add(this.dataGridView_Channel_old); this.panel_channelList.Location = new System.Drawing.Point(11, 227); this.panel_channelList.Name = "panel_channelList"; this.panel_channelList.Size = new System.Drawing.Size(1004, 420); @@ -569,6 +575,56 @@ this.pic_bootFeature_1.TabIndex = 319; this.pic_bootFeature_1.TabStop = false; // + // dataGridView_Channel_old + // + this.dataGridView_Channel_old.AllowUserToAddRows = false; + this.dataGridView_Channel_old.AllowUserToDeleteRows = false; + this.dataGridView_Channel_old.AllowUserToResizeColumns = false; + this.dataGridView_Channel_old.AllowUserToResizeRows = false; + dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6; + this.dataGridView_Channel_old.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView_Channel_old.BackgroundColor = System.Drawing.Color.White; + this.dataGridView_Channel_old.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dataGridView_Channel_old.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SunkenHorizontal; + this.dataGridView_Channel_old.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable; + this.dataGridView_Channel_old.ColumnHeadersHeight = 30; + this.dataGridView_Channel_old.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Channel_old.DefaultCellStyle = dataGridViewCellStyle7; + this.dataGridView_Channel_old.GridColor = System.Drawing.Color.DarkGray; + this.dataGridView_Channel_old.Location = new System.Drawing.Point(11, 10); + this.dataGridView_Channel_old.Margin = new System.Windows.Forms.Padding(0); + this.dataGridView_Channel_old.MultiSelect = false; + this.dataGridView_Channel_old.Name = "dataGridView_Channel_old"; + this.dataGridView_Channel_old.RowHeadersVisible = false; + this.dataGridView_Channel_old.RowHeadersWidth = 30; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.RowsDefaultCellStyle = dataGridViewCellStyle8; + this.dataGridView_Channel_old.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.Transparent; + this.dataGridView_Channel_old.RowTemplate.Height = 74; + this.dataGridView_Channel_old.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.dataGridView_Channel_old.Size = new System.Drawing.Size(984, 400); + this.dataGridView_Channel_old.TabIndex = 0; + this.dataGridView_Channel_old.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); + this.dataGridView_Channel_old.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + // // dataGridView_Channel // this.dataGridView_Channel.AllowUserToAddRows = false; @@ -577,7 +633,7 @@ this.dataGridView_Channel.AllowUserToResizeRows = false; dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -606,7 +662,7 @@ this.dataGridView_Channel.RowHeadersWidth = 30; dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -615,9 +671,9 @@ this.dataGridView_Channel.RowTemplate.Height = 74; this.dataGridView_Channel.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dataGridView_Channel.Size = new System.Drawing.Size(984, 400); - this.dataGridView_Channel.TabIndex = 0; - this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); - this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + this.dataGridView_Channel.TabIndex = 342; + this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick_1); + this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint_1); // // HomeCtrlForm // @@ -661,6 +717,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).EndInit(); this.ResumeLayout(false); @@ -679,7 +736,7 @@ private System.Windows.Forms.Button btnPre; private System.Windows.Forms.TextBox textBoxPage; private System.Windows.Forms.Button btnNext; - private System.Windows.Forms.DataGridView dataGridView_Channel; + private System.Windows.Forms.DataGridView dataGridView_Channel_old; private System.Windows.Forms.Label labelNodata; private System.Windows.Forms.PictureBox pic_accuracy_1; private System.Windows.Forms.PictureBox pic_ageRate_1; @@ -708,5 +765,6 @@ private System.Windows.Forms.Panel panel3; public System.Windows.Forms.Label label_receiverStatus; public System.Windows.Forms.Label label_clockStatus; + private MyDataGridView dataGridView_Channel; } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index ca3181d..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,335 +305,354 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + lock (obj) { - channelFreeList.Remove(device.Channel); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } + } } - } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { try { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); - channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else - { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); - } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[12].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; } catch (Exception ex) { @@ -646,23 +665,41 @@ { try { - dataGridView_Channel.ClearSelection(); + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - } - else - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + dataGridView_Channel.ClearSelection(); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); + int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); + if (channelFreeList.Contains(channelNo + "")) + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -729,26 +766,50 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else @@ -773,7 +834,51 @@ channelDlg.ShowDialog(); } - - + private void dataGridView_Channel_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) + { + cellDoubleClick(e.RowIndex); + } + + private void dataGridView_Channel_RowPostPaint_1(object sender, DataGridViewRowPostPaintEventArgs e) + { + try + { + lock (obj) + { + dataGridView_Channel.ClearSelection(); + + int channelNo = e.RowIndex + 1; + + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + + } + } } } diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index f99f106..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -47,6 +47,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); int channel = 0; + public Action HideMaskAction { @@ -66,9 +67,7 @@ SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 - CheckForIllegalCrossThreadCalls = false; - - + CheckForIllegalCrossThreadCalls = false; } private void btnExitChannel_Click(object sender, EventArgs e) @@ -158,6 +157,10 @@ MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -165,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1a82d85..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -30,6 +30,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); DeviceService deviceService = new DeviceServiceImpl(); + #region 无边框拖动效果/最小化窗口/关闭窗口 [DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); @@ -66,6 +67,7 @@ // 跨线程访问控件 CheckForIllegalCrossThreadCalls = false; + } // 开始检测 @@ -117,6 +119,10 @@ MessageBox.Show("无法打开串口" + portName + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -124,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 描述/端口 - Label colDevPort = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "描述", - Location = new Point(242, 0), - Size = new Size(50, 50) - }; - dataGridView_CounterResult.Controls.Add(colDevPort); - colDevPort.BringToFront(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px dataGridView_CounterResult.Columns[0].Width = 50; - dataGridView_CounterResult.Columns[1].Width = 95; - dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[3].Width = 50; - dataGridView_CounterResult.Columns[4].Width = 85; - dataGridView_CounterResult.Columns[5].Width = 105; - dataGridView_CounterResult.Columns[6].Width = 85; - dataGridView_CounterResult.Columns[7].Width = 129; + dataGridView_CounterResult.Columns[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index 09d1e4a..5fd129f 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -31,6 +31,9 @@ { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -73,7 +76,8 @@ this.pic_stability_1 = new System.Windows.Forms.PictureBox(); this.pic_accuracy_1 = new System.Windows.Forms.PictureBox(); this.pic_bootFeature_1 = new System.Windows.Forms.PictureBox(); - this.dataGridView_Channel = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel_old = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel = new Casic.Birmm.RbFreqStandMeasure.MyDataGridView(); this.panel_toTestDev.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tableToBeTested)).BeginInit(); this.panelBase.SuspendLayout(); @@ -103,6 +107,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).BeginInit(); this.SuspendLayout(); // @@ -299,6 +304,7 @@ this.panel_channelList.Controls.Add(this.panel2); this.panel_channelList.Controls.Add(this.panel1); this.panel_channelList.Controls.Add(this.dataGridView_Channel); + this.panel_channelList.Controls.Add(this.dataGridView_Channel_old); this.panel_channelList.Location = new System.Drawing.Point(11, 227); this.panel_channelList.Name = "panel_channelList"; this.panel_channelList.Size = new System.Drawing.Size(1004, 420); @@ -569,6 +575,56 @@ this.pic_bootFeature_1.TabIndex = 319; this.pic_bootFeature_1.TabStop = false; // + // dataGridView_Channel_old + // + this.dataGridView_Channel_old.AllowUserToAddRows = false; + this.dataGridView_Channel_old.AllowUserToDeleteRows = false; + this.dataGridView_Channel_old.AllowUserToResizeColumns = false; + this.dataGridView_Channel_old.AllowUserToResizeRows = false; + dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6; + this.dataGridView_Channel_old.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView_Channel_old.BackgroundColor = System.Drawing.Color.White; + this.dataGridView_Channel_old.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dataGridView_Channel_old.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SunkenHorizontal; + this.dataGridView_Channel_old.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable; + this.dataGridView_Channel_old.ColumnHeadersHeight = 30; + this.dataGridView_Channel_old.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Channel_old.DefaultCellStyle = dataGridViewCellStyle7; + this.dataGridView_Channel_old.GridColor = System.Drawing.Color.DarkGray; + this.dataGridView_Channel_old.Location = new System.Drawing.Point(11, 10); + this.dataGridView_Channel_old.Margin = new System.Windows.Forms.Padding(0); + this.dataGridView_Channel_old.MultiSelect = false; + this.dataGridView_Channel_old.Name = "dataGridView_Channel_old"; + this.dataGridView_Channel_old.RowHeadersVisible = false; + this.dataGridView_Channel_old.RowHeadersWidth = 30; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.RowsDefaultCellStyle = dataGridViewCellStyle8; + this.dataGridView_Channel_old.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.Transparent; + this.dataGridView_Channel_old.RowTemplate.Height = 74; + this.dataGridView_Channel_old.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.dataGridView_Channel_old.Size = new System.Drawing.Size(984, 400); + this.dataGridView_Channel_old.TabIndex = 0; + this.dataGridView_Channel_old.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); + this.dataGridView_Channel_old.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + // // dataGridView_Channel // this.dataGridView_Channel.AllowUserToAddRows = false; @@ -577,7 +633,7 @@ this.dataGridView_Channel.AllowUserToResizeRows = false; dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -606,7 +662,7 @@ this.dataGridView_Channel.RowHeadersWidth = 30; dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -615,9 +671,9 @@ this.dataGridView_Channel.RowTemplate.Height = 74; this.dataGridView_Channel.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dataGridView_Channel.Size = new System.Drawing.Size(984, 400); - this.dataGridView_Channel.TabIndex = 0; - this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); - this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + this.dataGridView_Channel.TabIndex = 342; + this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick_1); + this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint_1); // // HomeCtrlForm // @@ -661,6 +717,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).EndInit(); this.ResumeLayout(false); @@ -679,7 +736,7 @@ private System.Windows.Forms.Button btnPre; private System.Windows.Forms.TextBox textBoxPage; private System.Windows.Forms.Button btnNext; - private System.Windows.Forms.DataGridView dataGridView_Channel; + private System.Windows.Forms.DataGridView dataGridView_Channel_old; private System.Windows.Forms.Label labelNodata; private System.Windows.Forms.PictureBox pic_accuracy_1; private System.Windows.Forms.PictureBox pic_ageRate_1; @@ -708,5 +765,6 @@ private System.Windows.Forms.Panel panel3; public System.Windows.Forms.Label label_receiverStatus; public System.Windows.Forms.Label label_clockStatus; + private MyDataGridView dataGridView_Channel; } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index ca3181d..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,335 +305,354 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + lock (obj) { - channelFreeList.Remove(device.Channel); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } + } } - } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { try { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); - channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else - { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); - } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[12].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; } catch (Exception ex) { @@ -646,23 +665,41 @@ { try { - dataGridView_Channel.ClearSelection(); + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - } - else - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + dataGridView_Channel.ClearSelection(); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); + int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); + if (channelFreeList.Contains(channelNo + "")) + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -729,26 +766,50 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else @@ -773,7 +834,51 @@ channelDlg.ShowDialog(); } - - + private void dataGridView_Channel_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) + { + cellDoubleClick(e.RowIndex); + } + + private void dataGridView_Channel_RowPostPaint_1(object sender, DataGridViewRowPostPaintEventArgs e) + { + try + { + lock (obj) + { + dataGridView_Channel.ClearSelection(); + + int channelNo = e.RowIndex + 1; + + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + + } + } } } diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index f99f106..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -47,6 +47,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); int channel = 0; + public Action HideMaskAction { @@ -66,9 +67,7 @@ SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 - CheckForIllegalCrossThreadCalls = false; - - + CheckForIllegalCrossThreadCalls = false; } private void btnExitChannel_Click(object sender, EventArgs e) @@ -158,6 +157,10 @@ MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -165,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1a82d85..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -30,6 +30,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); DeviceService deviceService = new DeviceServiceImpl(); + #region 无边框拖动效果/最小化窗口/关闭窗口 [DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); @@ -66,6 +67,7 @@ // 跨线程访问控件 CheckForIllegalCrossThreadCalls = false; + } // 开始检测 @@ -117,6 +119,10 @@ MessageBox.Show("无法打开串口" + portName + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -124,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index ed117e0..46d4778 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -47,7 +47,6 @@ public long deviceId = -1; public static bool isInDetection = false; - public Action HideMaskAction { get; @@ -77,7 +76,8 @@ text_channelNo.WatermarkText = "无空闲通道"; groupBox1.Enabled = false; } - + + } // 关闭对话框 @@ -208,6 +208,10 @@ MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -217,7 +221,7 @@ try { - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); return; diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 描述/端口 - Label colDevPort = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "描述", - Location = new Point(242, 0), - Size = new Size(50, 50) - }; - dataGridView_CounterResult.Controls.Add(colDevPort); - colDevPort.BringToFront(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px dataGridView_CounterResult.Columns[0].Width = 50; - dataGridView_CounterResult.Columns[1].Width = 95; - dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[3].Width = 50; - dataGridView_CounterResult.Columns[4].Width = 85; - dataGridView_CounterResult.Columns[5].Width = 105; - dataGridView_CounterResult.Columns[6].Width = 85; - dataGridView_CounterResult.Columns[7].Width = 129; + dataGridView_CounterResult.Columns[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index 09d1e4a..5fd129f 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -31,6 +31,9 @@ { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -73,7 +76,8 @@ this.pic_stability_1 = new System.Windows.Forms.PictureBox(); this.pic_accuracy_1 = new System.Windows.Forms.PictureBox(); this.pic_bootFeature_1 = new System.Windows.Forms.PictureBox(); - this.dataGridView_Channel = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel_old = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel = new Casic.Birmm.RbFreqStandMeasure.MyDataGridView(); this.panel_toTestDev.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tableToBeTested)).BeginInit(); this.panelBase.SuspendLayout(); @@ -103,6 +107,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).BeginInit(); this.SuspendLayout(); // @@ -299,6 +304,7 @@ this.panel_channelList.Controls.Add(this.panel2); this.panel_channelList.Controls.Add(this.panel1); this.panel_channelList.Controls.Add(this.dataGridView_Channel); + this.panel_channelList.Controls.Add(this.dataGridView_Channel_old); this.panel_channelList.Location = new System.Drawing.Point(11, 227); this.panel_channelList.Name = "panel_channelList"; this.panel_channelList.Size = new System.Drawing.Size(1004, 420); @@ -569,6 +575,56 @@ this.pic_bootFeature_1.TabIndex = 319; this.pic_bootFeature_1.TabStop = false; // + // dataGridView_Channel_old + // + this.dataGridView_Channel_old.AllowUserToAddRows = false; + this.dataGridView_Channel_old.AllowUserToDeleteRows = false; + this.dataGridView_Channel_old.AllowUserToResizeColumns = false; + this.dataGridView_Channel_old.AllowUserToResizeRows = false; + dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6; + this.dataGridView_Channel_old.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView_Channel_old.BackgroundColor = System.Drawing.Color.White; + this.dataGridView_Channel_old.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dataGridView_Channel_old.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SunkenHorizontal; + this.dataGridView_Channel_old.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable; + this.dataGridView_Channel_old.ColumnHeadersHeight = 30; + this.dataGridView_Channel_old.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Channel_old.DefaultCellStyle = dataGridViewCellStyle7; + this.dataGridView_Channel_old.GridColor = System.Drawing.Color.DarkGray; + this.dataGridView_Channel_old.Location = new System.Drawing.Point(11, 10); + this.dataGridView_Channel_old.Margin = new System.Windows.Forms.Padding(0); + this.dataGridView_Channel_old.MultiSelect = false; + this.dataGridView_Channel_old.Name = "dataGridView_Channel_old"; + this.dataGridView_Channel_old.RowHeadersVisible = false; + this.dataGridView_Channel_old.RowHeadersWidth = 30; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.RowsDefaultCellStyle = dataGridViewCellStyle8; + this.dataGridView_Channel_old.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.Transparent; + this.dataGridView_Channel_old.RowTemplate.Height = 74; + this.dataGridView_Channel_old.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.dataGridView_Channel_old.Size = new System.Drawing.Size(984, 400); + this.dataGridView_Channel_old.TabIndex = 0; + this.dataGridView_Channel_old.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); + this.dataGridView_Channel_old.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + // // dataGridView_Channel // this.dataGridView_Channel.AllowUserToAddRows = false; @@ -577,7 +633,7 @@ this.dataGridView_Channel.AllowUserToResizeRows = false; dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -606,7 +662,7 @@ this.dataGridView_Channel.RowHeadersWidth = 30; dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -615,9 +671,9 @@ this.dataGridView_Channel.RowTemplate.Height = 74; this.dataGridView_Channel.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dataGridView_Channel.Size = new System.Drawing.Size(984, 400); - this.dataGridView_Channel.TabIndex = 0; - this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); - this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + this.dataGridView_Channel.TabIndex = 342; + this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick_1); + this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint_1); // // HomeCtrlForm // @@ -661,6 +717,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).EndInit(); this.ResumeLayout(false); @@ -679,7 +736,7 @@ private System.Windows.Forms.Button btnPre; private System.Windows.Forms.TextBox textBoxPage; private System.Windows.Forms.Button btnNext; - private System.Windows.Forms.DataGridView dataGridView_Channel; + private System.Windows.Forms.DataGridView dataGridView_Channel_old; private System.Windows.Forms.Label labelNodata; private System.Windows.Forms.PictureBox pic_accuracy_1; private System.Windows.Forms.PictureBox pic_ageRate_1; @@ -708,5 +765,6 @@ private System.Windows.Forms.Panel panel3; public System.Windows.Forms.Label label_receiverStatus; public System.Windows.Forms.Label label_clockStatus; + private MyDataGridView dataGridView_Channel; } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index ca3181d..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,335 +305,354 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + lock (obj) { - channelFreeList.Remove(device.Channel); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } + } } - } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { try { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); - channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else - { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); - } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[12].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; } catch (Exception ex) { @@ -646,23 +665,41 @@ { try { - dataGridView_Channel.ClearSelection(); + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - } - else - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + dataGridView_Channel.ClearSelection(); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); + int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); + if (channelFreeList.Contains(channelNo + "")) + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -729,26 +766,50 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else @@ -773,7 +834,51 @@ channelDlg.ShowDialog(); } - - + private void dataGridView_Channel_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) + { + cellDoubleClick(e.RowIndex); + } + + private void dataGridView_Channel_RowPostPaint_1(object sender, DataGridViewRowPostPaintEventArgs e) + { + try + { + lock (obj) + { + dataGridView_Channel.ClearSelection(); + + int channelNo = e.RowIndex + 1; + + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + + } + } } } diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index f99f106..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -47,6 +47,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); int channel = 0; + public Action HideMaskAction { @@ -66,9 +67,7 @@ SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 - CheckForIllegalCrossThreadCalls = false; - - + CheckForIllegalCrossThreadCalls = false; } private void btnExitChannel_Click(object sender, EventArgs e) @@ -158,6 +157,10 @@ MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -165,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1a82d85..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -30,6 +30,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); DeviceService deviceService = new DeviceServiceImpl(); + #region 无边框拖动效果/最小化窗口/关闭窗口 [DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); @@ -66,6 +67,7 @@ // 跨线程访问控件 CheckForIllegalCrossThreadCalls = false; + } // 开始检测 @@ -117,6 +119,10 @@ MessageBox.Show("无法打开串口" + portName + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -124,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index ed117e0..46d4778 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -47,7 +47,6 @@ public long deviceId = -1; public static bool isInDetection = false; - public Action HideMaskAction { get; @@ -77,7 +76,8 @@ text_channelNo.WatermarkText = "无空闲通道"; groupBox1.Enabled = false; } - + + } // 关闭对话框 @@ -208,6 +208,10 @@ MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -217,7 +221,7 @@ try { - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); return; diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index e0c40b6..ad05a32 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -337,7 +337,12 @@ groupBox3.Text = "1s频率稳定度"; stability result = new stability(); result.label_stability.Text = ""; - if (!resultStaStr1.Equals("-1")&& !resultStaStr1.Equals("-2")&&!resultStaStr1.Equals("-3")) result.label_stability.Text = resultStaStr1; + result.label_count.Text = ""; + if (!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3")) + { + result.label_stability.Text = resultStaStr1; + result.label_count.Text = "101"; + } result.Show(); panel_result.Controls.Add(result); diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 描述/端口 - Label colDevPort = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "描述", - Location = new Point(242, 0), - Size = new Size(50, 50) - }; - dataGridView_CounterResult.Controls.Add(colDevPort); - colDevPort.BringToFront(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px dataGridView_CounterResult.Columns[0].Width = 50; - dataGridView_CounterResult.Columns[1].Width = 95; - dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[3].Width = 50; - dataGridView_CounterResult.Columns[4].Width = 85; - dataGridView_CounterResult.Columns[5].Width = 105; - dataGridView_CounterResult.Columns[6].Width = 85; - dataGridView_CounterResult.Columns[7].Width = 129; + dataGridView_CounterResult.Columns[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index 09d1e4a..5fd129f 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -31,6 +31,9 @@ { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -73,7 +76,8 @@ this.pic_stability_1 = new System.Windows.Forms.PictureBox(); this.pic_accuracy_1 = new System.Windows.Forms.PictureBox(); this.pic_bootFeature_1 = new System.Windows.Forms.PictureBox(); - this.dataGridView_Channel = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel_old = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel = new Casic.Birmm.RbFreqStandMeasure.MyDataGridView(); this.panel_toTestDev.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tableToBeTested)).BeginInit(); this.panelBase.SuspendLayout(); @@ -103,6 +107,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).BeginInit(); this.SuspendLayout(); // @@ -299,6 +304,7 @@ this.panel_channelList.Controls.Add(this.panel2); this.panel_channelList.Controls.Add(this.panel1); this.panel_channelList.Controls.Add(this.dataGridView_Channel); + this.panel_channelList.Controls.Add(this.dataGridView_Channel_old); this.panel_channelList.Location = new System.Drawing.Point(11, 227); this.panel_channelList.Name = "panel_channelList"; this.panel_channelList.Size = new System.Drawing.Size(1004, 420); @@ -569,6 +575,56 @@ this.pic_bootFeature_1.TabIndex = 319; this.pic_bootFeature_1.TabStop = false; // + // dataGridView_Channel_old + // + this.dataGridView_Channel_old.AllowUserToAddRows = false; + this.dataGridView_Channel_old.AllowUserToDeleteRows = false; + this.dataGridView_Channel_old.AllowUserToResizeColumns = false; + this.dataGridView_Channel_old.AllowUserToResizeRows = false; + dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6; + this.dataGridView_Channel_old.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView_Channel_old.BackgroundColor = System.Drawing.Color.White; + this.dataGridView_Channel_old.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dataGridView_Channel_old.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SunkenHorizontal; + this.dataGridView_Channel_old.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable; + this.dataGridView_Channel_old.ColumnHeadersHeight = 30; + this.dataGridView_Channel_old.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Channel_old.DefaultCellStyle = dataGridViewCellStyle7; + this.dataGridView_Channel_old.GridColor = System.Drawing.Color.DarkGray; + this.dataGridView_Channel_old.Location = new System.Drawing.Point(11, 10); + this.dataGridView_Channel_old.Margin = new System.Windows.Forms.Padding(0); + this.dataGridView_Channel_old.MultiSelect = false; + this.dataGridView_Channel_old.Name = "dataGridView_Channel_old"; + this.dataGridView_Channel_old.RowHeadersVisible = false; + this.dataGridView_Channel_old.RowHeadersWidth = 30; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.RowsDefaultCellStyle = dataGridViewCellStyle8; + this.dataGridView_Channel_old.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.Transparent; + this.dataGridView_Channel_old.RowTemplate.Height = 74; + this.dataGridView_Channel_old.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.dataGridView_Channel_old.Size = new System.Drawing.Size(984, 400); + this.dataGridView_Channel_old.TabIndex = 0; + this.dataGridView_Channel_old.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); + this.dataGridView_Channel_old.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + // // dataGridView_Channel // this.dataGridView_Channel.AllowUserToAddRows = false; @@ -577,7 +633,7 @@ this.dataGridView_Channel.AllowUserToResizeRows = false; dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -606,7 +662,7 @@ this.dataGridView_Channel.RowHeadersWidth = 30; dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -615,9 +671,9 @@ this.dataGridView_Channel.RowTemplate.Height = 74; this.dataGridView_Channel.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dataGridView_Channel.Size = new System.Drawing.Size(984, 400); - this.dataGridView_Channel.TabIndex = 0; - this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); - this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + this.dataGridView_Channel.TabIndex = 342; + this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick_1); + this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint_1); // // HomeCtrlForm // @@ -661,6 +717,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).EndInit(); this.ResumeLayout(false); @@ -679,7 +736,7 @@ private System.Windows.Forms.Button btnPre; private System.Windows.Forms.TextBox textBoxPage; private System.Windows.Forms.Button btnNext; - private System.Windows.Forms.DataGridView dataGridView_Channel; + private System.Windows.Forms.DataGridView dataGridView_Channel_old; private System.Windows.Forms.Label labelNodata; private System.Windows.Forms.PictureBox pic_accuracy_1; private System.Windows.Forms.PictureBox pic_ageRate_1; @@ -708,5 +765,6 @@ private System.Windows.Forms.Panel panel3; public System.Windows.Forms.Label label_receiverStatus; public System.Windows.Forms.Label label_clockStatus; + private MyDataGridView dataGridView_Channel; } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index ca3181d..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,335 +305,354 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + lock (obj) { - channelFreeList.Remove(device.Channel); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } + } } - } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { try { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); - channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else - { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); - } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[12].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; } catch (Exception ex) { @@ -646,23 +665,41 @@ { try { - dataGridView_Channel.ClearSelection(); + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - } - else - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + dataGridView_Channel.ClearSelection(); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); + int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); + if (channelFreeList.Contains(channelNo + "")) + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -729,26 +766,50 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else @@ -773,7 +834,51 @@ channelDlg.ShowDialog(); } - - + private void dataGridView_Channel_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) + { + cellDoubleClick(e.RowIndex); + } + + private void dataGridView_Channel_RowPostPaint_1(object sender, DataGridViewRowPostPaintEventArgs e) + { + try + { + lock (obj) + { + dataGridView_Channel.ClearSelection(); + + int channelNo = e.RowIndex + 1; + + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + + } + } } } diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index f99f106..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -47,6 +47,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); int channel = 0; + public Action HideMaskAction { @@ -66,9 +67,7 @@ SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 - CheckForIllegalCrossThreadCalls = false; - - + CheckForIllegalCrossThreadCalls = false; } private void btnExitChannel_Click(object sender, EventArgs e) @@ -158,6 +157,10 @@ MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -165,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1a82d85..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -30,6 +30,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); DeviceService deviceService = new DeviceServiceImpl(); + #region 无边框拖动效果/最小化窗口/关闭窗口 [DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); @@ -66,6 +67,7 @@ // 跨线程访问控件 CheckForIllegalCrossThreadCalls = false; + } // 开始检测 @@ -117,6 +119,10 @@ MessageBox.Show("无法打开串口" + portName + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -124,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index ed117e0..46d4778 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -47,7 +47,6 @@ public long deviceId = -1; public static bool isInDetection = false; - public Action HideMaskAction { get; @@ -77,7 +76,8 @@ text_channelNo.WatermarkText = "无空闲通道"; groupBox1.Enabled = false; } - + + } // 关闭对话框 @@ -208,6 +208,10 @@ MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -217,7 +221,7 @@ try { - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); return; diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index e0c40b6..ad05a32 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -337,7 +337,12 @@ groupBox3.Text = "1s频率稳定度"; stability result = new stability(); result.label_stability.Text = ""; - if (!resultStaStr1.Equals("-1")&& !resultStaStr1.Equals("-2")&&!resultStaStr1.Equals("-3")) result.label_stability.Text = resultStaStr1; + result.label_count.Text = ""; + if (!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3")) + { + result.label_stability.Text = resultStaStr1; + result.label_count.Text = "101"; + } result.Show(); panel_result.Controls.Add(result); diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 19e2f83..cfb23dd 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -133,7 +133,7 @@ } DetectionHelper detectionHelper = new DetectionHelper(); - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNoReDetec + "]!"); btn_reDetec.Enabled = true; diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 描述/端口 - Label colDevPort = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "描述", - Location = new Point(242, 0), - Size = new Size(50, 50) - }; - dataGridView_CounterResult.Controls.Add(colDevPort); - colDevPort.BringToFront(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px dataGridView_CounterResult.Columns[0].Width = 50; - dataGridView_CounterResult.Columns[1].Width = 95; - dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[3].Width = 50; - dataGridView_CounterResult.Columns[4].Width = 85; - dataGridView_CounterResult.Columns[5].Width = 105; - dataGridView_CounterResult.Columns[6].Width = 85; - dataGridView_CounterResult.Columns[7].Width = 129; + dataGridView_CounterResult.Columns[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index 09d1e4a..5fd129f 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -31,6 +31,9 @@ { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -73,7 +76,8 @@ this.pic_stability_1 = new System.Windows.Forms.PictureBox(); this.pic_accuracy_1 = new System.Windows.Forms.PictureBox(); this.pic_bootFeature_1 = new System.Windows.Forms.PictureBox(); - this.dataGridView_Channel = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel_old = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel = new Casic.Birmm.RbFreqStandMeasure.MyDataGridView(); this.panel_toTestDev.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tableToBeTested)).BeginInit(); this.panelBase.SuspendLayout(); @@ -103,6 +107,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).BeginInit(); this.SuspendLayout(); // @@ -299,6 +304,7 @@ this.panel_channelList.Controls.Add(this.panel2); this.panel_channelList.Controls.Add(this.panel1); this.panel_channelList.Controls.Add(this.dataGridView_Channel); + this.panel_channelList.Controls.Add(this.dataGridView_Channel_old); this.panel_channelList.Location = new System.Drawing.Point(11, 227); this.panel_channelList.Name = "panel_channelList"; this.panel_channelList.Size = new System.Drawing.Size(1004, 420); @@ -569,6 +575,56 @@ this.pic_bootFeature_1.TabIndex = 319; this.pic_bootFeature_1.TabStop = false; // + // dataGridView_Channel_old + // + this.dataGridView_Channel_old.AllowUserToAddRows = false; + this.dataGridView_Channel_old.AllowUserToDeleteRows = false; + this.dataGridView_Channel_old.AllowUserToResizeColumns = false; + this.dataGridView_Channel_old.AllowUserToResizeRows = false; + dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6; + this.dataGridView_Channel_old.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView_Channel_old.BackgroundColor = System.Drawing.Color.White; + this.dataGridView_Channel_old.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dataGridView_Channel_old.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SunkenHorizontal; + this.dataGridView_Channel_old.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable; + this.dataGridView_Channel_old.ColumnHeadersHeight = 30; + this.dataGridView_Channel_old.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Channel_old.DefaultCellStyle = dataGridViewCellStyle7; + this.dataGridView_Channel_old.GridColor = System.Drawing.Color.DarkGray; + this.dataGridView_Channel_old.Location = new System.Drawing.Point(11, 10); + this.dataGridView_Channel_old.Margin = new System.Windows.Forms.Padding(0); + this.dataGridView_Channel_old.MultiSelect = false; + this.dataGridView_Channel_old.Name = "dataGridView_Channel_old"; + this.dataGridView_Channel_old.RowHeadersVisible = false; + this.dataGridView_Channel_old.RowHeadersWidth = 30; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.RowsDefaultCellStyle = dataGridViewCellStyle8; + this.dataGridView_Channel_old.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.Transparent; + this.dataGridView_Channel_old.RowTemplate.Height = 74; + this.dataGridView_Channel_old.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.dataGridView_Channel_old.Size = new System.Drawing.Size(984, 400); + this.dataGridView_Channel_old.TabIndex = 0; + this.dataGridView_Channel_old.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); + this.dataGridView_Channel_old.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + // // dataGridView_Channel // this.dataGridView_Channel.AllowUserToAddRows = false; @@ -577,7 +633,7 @@ this.dataGridView_Channel.AllowUserToResizeRows = false; dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -606,7 +662,7 @@ this.dataGridView_Channel.RowHeadersWidth = 30; dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -615,9 +671,9 @@ this.dataGridView_Channel.RowTemplate.Height = 74; this.dataGridView_Channel.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dataGridView_Channel.Size = new System.Drawing.Size(984, 400); - this.dataGridView_Channel.TabIndex = 0; - this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); - this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + this.dataGridView_Channel.TabIndex = 342; + this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick_1); + this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint_1); // // HomeCtrlForm // @@ -661,6 +717,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).EndInit(); this.ResumeLayout(false); @@ -679,7 +736,7 @@ private System.Windows.Forms.Button btnPre; private System.Windows.Forms.TextBox textBoxPage; private System.Windows.Forms.Button btnNext; - private System.Windows.Forms.DataGridView dataGridView_Channel; + private System.Windows.Forms.DataGridView dataGridView_Channel_old; private System.Windows.Forms.Label labelNodata; private System.Windows.Forms.PictureBox pic_accuracy_1; private System.Windows.Forms.PictureBox pic_ageRate_1; @@ -708,5 +765,6 @@ private System.Windows.Forms.Panel panel3; public System.Windows.Forms.Label label_receiverStatus; public System.Windows.Forms.Label label_clockStatus; + private MyDataGridView dataGridView_Channel; } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index ca3181d..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,335 +305,354 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + lock (obj) { - channelFreeList.Remove(device.Channel); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } + } } - } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { try { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); - channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else - { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); - } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[12].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; } catch (Exception ex) { @@ -646,23 +665,41 @@ { try { - dataGridView_Channel.ClearSelection(); + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - } - else - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + dataGridView_Channel.ClearSelection(); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); + int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); + if (channelFreeList.Contains(channelNo + "")) + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -729,26 +766,50 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else @@ -773,7 +834,51 @@ channelDlg.ShowDialog(); } - - + private void dataGridView_Channel_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) + { + cellDoubleClick(e.RowIndex); + } + + private void dataGridView_Channel_RowPostPaint_1(object sender, DataGridViewRowPostPaintEventArgs e) + { + try + { + lock (obj) + { + dataGridView_Channel.ClearSelection(); + + int channelNo = e.RowIndex + 1; + + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + + } + } } } diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index f99f106..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -47,6 +47,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); int channel = 0; + public Action HideMaskAction { @@ -66,9 +67,7 @@ SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 - CheckForIllegalCrossThreadCalls = false; - - + CheckForIllegalCrossThreadCalls = false; } private void btnExitChannel_Click(object sender, EventArgs e) @@ -158,6 +157,10 @@ MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -165,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1a82d85..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -30,6 +30,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); DeviceService deviceService = new DeviceServiceImpl(); + #region 无边框拖动效果/最小化窗口/关闭窗口 [DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); @@ -66,6 +67,7 @@ // 跨线程访问控件 CheckForIllegalCrossThreadCalls = false; + } // 开始检测 @@ -117,6 +119,10 @@ MessageBox.Show("无法打开串口" + portName + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -124,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index ed117e0..46d4778 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -47,7 +47,6 @@ public long deviceId = -1; public static bool isInDetection = false; - public Action HideMaskAction { get; @@ -77,7 +76,8 @@ text_channelNo.WatermarkText = "无空闲通道"; groupBox1.Enabled = false; } - + + } // 关闭对话框 @@ -208,6 +208,10 @@ MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -217,7 +221,7 @@ try { - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); return; diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index e0c40b6..ad05a32 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -337,7 +337,12 @@ groupBox3.Text = "1s频率稳定度"; stability result = new stability(); result.label_stability.Text = ""; - if (!resultStaStr1.Equals("-1")&& !resultStaStr1.Equals("-2")&&!resultStaStr1.Equals("-3")) result.label_stability.Text = resultStaStr1; + result.label_count.Text = ""; + if (!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3")) + { + result.label_stability.Text = resultStaStr1; + result.label_count.Text = "101"; + } result.Show(); panel_result.Controls.Add(result); diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 19e2f83..cfb23dd 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -133,7 +133,7 @@ } DetectionHelper detectionHelper = new DetectionHelper(); - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNoReDetec + "]!"); btn_reDetec.Enabled = true; diff --git a/RbFreqStandMeasure/info/stability.designer.cs b/RbFreqStandMeasure/info/stability.designer.cs index e9dc1c9..40caec5 100644 --- a/RbFreqStandMeasure/info/stability.designer.cs +++ b/RbFreqStandMeasure/info/stability.designer.cs @@ -44,7 +44,6 @@ this.label_count.Name = "label_count"; this.label_count.Size = new System.Drawing.Size(83, 27); this.label_count.TabIndex = 82; - this.label_count.Text = "101"; this.label_count.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // label_stability @@ -98,9 +97,9 @@ } #endregion - private System.Windows.Forms.Label label_count; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label9; public System.Windows.Forms.Label label_stability; + public System.Windows.Forms.Label label_count; } } diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 描述/端口 - Label colDevPort = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "描述", - Location = new Point(242, 0), - Size = new Size(50, 50) - }; - dataGridView_CounterResult.Controls.Add(colDevPort); - colDevPort.BringToFront(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px dataGridView_CounterResult.Columns[0].Width = 50; - dataGridView_CounterResult.Columns[1].Width = 95; - dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[3].Width = 50; - dataGridView_CounterResult.Columns[4].Width = 85; - dataGridView_CounterResult.Columns[5].Width = 105; - dataGridView_CounterResult.Columns[6].Width = 85; - dataGridView_CounterResult.Columns[7].Width = 129; + dataGridView_CounterResult.Columns[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index 09d1e4a..5fd129f 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -31,6 +31,9 @@ { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -73,7 +76,8 @@ this.pic_stability_1 = new System.Windows.Forms.PictureBox(); this.pic_accuracy_1 = new System.Windows.Forms.PictureBox(); this.pic_bootFeature_1 = new System.Windows.Forms.PictureBox(); - this.dataGridView_Channel = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel_old = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel = new Casic.Birmm.RbFreqStandMeasure.MyDataGridView(); this.panel_toTestDev.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tableToBeTested)).BeginInit(); this.panelBase.SuspendLayout(); @@ -103,6 +107,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).BeginInit(); this.SuspendLayout(); // @@ -299,6 +304,7 @@ this.panel_channelList.Controls.Add(this.panel2); this.panel_channelList.Controls.Add(this.panel1); this.panel_channelList.Controls.Add(this.dataGridView_Channel); + this.panel_channelList.Controls.Add(this.dataGridView_Channel_old); this.panel_channelList.Location = new System.Drawing.Point(11, 227); this.panel_channelList.Name = "panel_channelList"; this.panel_channelList.Size = new System.Drawing.Size(1004, 420); @@ -569,6 +575,56 @@ this.pic_bootFeature_1.TabIndex = 319; this.pic_bootFeature_1.TabStop = false; // + // dataGridView_Channel_old + // + this.dataGridView_Channel_old.AllowUserToAddRows = false; + this.dataGridView_Channel_old.AllowUserToDeleteRows = false; + this.dataGridView_Channel_old.AllowUserToResizeColumns = false; + this.dataGridView_Channel_old.AllowUserToResizeRows = false; + dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6; + this.dataGridView_Channel_old.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView_Channel_old.BackgroundColor = System.Drawing.Color.White; + this.dataGridView_Channel_old.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dataGridView_Channel_old.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SunkenHorizontal; + this.dataGridView_Channel_old.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable; + this.dataGridView_Channel_old.ColumnHeadersHeight = 30; + this.dataGridView_Channel_old.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Channel_old.DefaultCellStyle = dataGridViewCellStyle7; + this.dataGridView_Channel_old.GridColor = System.Drawing.Color.DarkGray; + this.dataGridView_Channel_old.Location = new System.Drawing.Point(11, 10); + this.dataGridView_Channel_old.Margin = new System.Windows.Forms.Padding(0); + this.dataGridView_Channel_old.MultiSelect = false; + this.dataGridView_Channel_old.Name = "dataGridView_Channel_old"; + this.dataGridView_Channel_old.RowHeadersVisible = false; + this.dataGridView_Channel_old.RowHeadersWidth = 30; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.RowsDefaultCellStyle = dataGridViewCellStyle8; + this.dataGridView_Channel_old.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.Transparent; + this.dataGridView_Channel_old.RowTemplate.Height = 74; + this.dataGridView_Channel_old.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.dataGridView_Channel_old.Size = new System.Drawing.Size(984, 400); + this.dataGridView_Channel_old.TabIndex = 0; + this.dataGridView_Channel_old.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); + this.dataGridView_Channel_old.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + // // dataGridView_Channel // this.dataGridView_Channel.AllowUserToAddRows = false; @@ -577,7 +633,7 @@ this.dataGridView_Channel.AllowUserToResizeRows = false; dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -606,7 +662,7 @@ this.dataGridView_Channel.RowHeadersWidth = 30; dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -615,9 +671,9 @@ this.dataGridView_Channel.RowTemplate.Height = 74; this.dataGridView_Channel.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dataGridView_Channel.Size = new System.Drawing.Size(984, 400); - this.dataGridView_Channel.TabIndex = 0; - this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); - this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + this.dataGridView_Channel.TabIndex = 342; + this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick_1); + this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint_1); // // HomeCtrlForm // @@ -661,6 +717,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).EndInit(); this.ResumeLayout(false); @@ -679,7 +736,7 @@ private System.Windows.Forms.Button btnPre; private System.Windows.Forms.TextBox textBoxPage; private System.Windows.Forms.Button btnNext; - private System.Windows.Forms.DataGridView dataGridView_Channel; + private System.Windows.Forms.DataGridView dataGridView_Channel_old; private System.Windows.Forms.Label labelNodata; private System.Windows.Forms.PictureBox pic_accuracy_1; private System.Windows.Forms.PictureBox pic_ageRate_1; @@ -708,5 +765,6 @@ private System.Windows.Forms.Panel panel3; public System.Windows.Forms.Label label_receiverStatus; public System.Windows.Forms.Label label_clockStatus; + private MyDataGridView dataGridView_Channel; } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index ca3181d..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,335 +305,354 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + lock (obj) { - channelFreeList.Remove(device.Channel); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } + } } - } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { try { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); - channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else - { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); - } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[12].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; } catch (Exception ex) { @@ -646,23 +665,41 @@ { try { - dataGridView_Channel.ClearSelection(); + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - } - else - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + dataGridView_Channel.ClearSelection(); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); + int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); + if (channelFreeList.Contains(channelNo + "")) + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -729,26 +766,50 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else @@ -773,7 +834,51 @@ channelDlg.ShowDialog(); } - - + private void dataGridView_Channel_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) + { + cellDoubleClick(e.RowIndex); + } + + private void dataGridView_Channel_RowPostPaint_1(object sender, DataGridViewRowPostPaintEventArgs e) + { + try + { + lock (obj) + { + dataGridView_Channel.ClearSelection(); + + int channelNo = e.RowIndex + 1; + + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + + } + } } } diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index f99f106..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -47,6 +47,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); int channel = 0; + public Action HideMaskAction { @@ -66,9 +67,7 @@ SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 - CheckForIllegalCrossThreadCalls = false; - - + CheckForIllegalCrossThreadCalls = false; } private void btnExitChannel_Click(object sender, EventArgs e) @@ -158,6 +157,10 @@ MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -165,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1a82d85..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -30,6 +30,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); DeviceService deviceService = new DeviceServiceImpl(); + #region 无边框拖动效果/最小化窗口/关闭窗口 [DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); @@ -66,6 +67,7 @@ // 跨线程访问控件 CheckForIllegalCrossThreadCalls = false; + } // 开始检测 @@ -117,6 +119,10 @@ MessageBox.Show("无法打开串口" + portName + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -124,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index ed117e0..46d4778 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -47,7 +47,6 @@ public long deviceId = -1; public static bool isInDetection = false; - public Action HideMaskAction { get; @@ -77,7 +76,8 @@ text_channelNo.WatermarkText = "无空闲通道"; groupBox1.Enabled = false; } - + + } // 关闭对话框 @@ -208,6 +208,10 @@ MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -217,7 +221,7 @@ try { - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); return; diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index e0c40b6..ad05a32 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -337,7 +337,12 @@ groupBox3.Text = "1s频率稳定度"; stability result = new stability(); result.label_stability.Text = ""; - if (!resultStaStr1.Equals("-1")&& !resultStaStr1.Equals("-2")&&!resultStaStr1.Equals("-3")) result.label_stability.Text = resultStaStr1; + result.label_count.Text = ""; + if (!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3")) + { + result.label_stability.Text = resultStaStr1; + result.label_count.Text = "101"; + } result.Show(); panel_result.Controls.Add(result); diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 19e2f83..cfb23dd 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -133,7 +133,7 @@ } DetectionHelper detectionHelper = new DetectionHelper(); - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNoReDetec + "]!"); btn_reDetec.Enabled = true; diff --git a/RbFreqStandMeasure/info/stability.designer.cs b/RbFreqStandMeasure/info/stability.designer.cs index e9dc1c9..40caec5 100644 --- a/RbFreqStandMeasure/info/stability.designer.cs +++ b/RbFreqStandMeasure/info/stability.designer.cs @@ -44,7 +44,6 @@ this.label_count.Name = "label_count"; this.label_count.Size = new System.Drawing.Size(83, 27); this.label_count.TabIndex = 82; - this.label_count.Text = "101"; this.label_count.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // label_stability @@ -98,9 +97,9 @@ } #endregion - private System.Windows.Forms.Label label_count; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label9; public System.Windows.Forms.Label label_stability; + public System.Windows.Forms.Label label_count; } } diff --git a/RbFreqStandMeasure/status/StatusCtrlForm.cs b/RbFreqStandMeasure/status/StatusCtrlForm.cs index 44a5302..8a7853d 100644 --- a/RbFreqStandMeasure/status/StatusCtrlForm.cs +++ b/RbFreqStandMeasure/status/StatusCtrlForm.cs @@ -137,8 +137,7 @@ { if ((i + 3) < arr.Length && !arr[i + 1].Equals("") && !arr[i + 2].Equals("") && !arr[i + 3].Equals("")) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, arr[i + 1] + ";" + arr[i + 2] + ";" + arr[i + 3]); - + int Elevation = Convert.ToInt32(arr[i + 1]); int azimuth = Convert.ToInt32(arr[i + 2]); double cosLen = Math.Cos(Elevation * Math.PI / 180) * (575 / 2); @@ -168,8 +167,7 @@ { if ((i + 3) < arr.Length && !arr[i + 1].Equals("") && !arr[i + 2].Equals("") && !arr[i + 3].Equals("")) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, arr[i + 1] + ";" + arr[i + 2] + ";" + arr[i + 3]); - + int Elevation = Convert.ToInt32(arr[i + 1]); int azimuth = Convert.ToInt32(arr[i + 2]); double cosLen = Math.Cos(Elevation * Math.PI / 180) * (575 / 2); @@ -258,7 +256,7 @@ if (!portSatellite.IsOpen) portSatellite.Open(); if (portSatellite.IsOpen) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "打开串口成功!" + portName); + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "打开卫星状态串口成功!" + portName); } else { @@ -379,7 +377,6 @@ } else if ((sss.Contains("GPGSV") || sss.Contains("BDGSV") || sss.Contains("GBGSV")) && sss.Contains("*")) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "GSV : " + sss); if (sss.Split(',').Length > 8) { if (sss.Contains("GPGSV")) @@ -400,9 +397,7 @@ totalBD = Convert.ToInt32(sss.Split(',')[3]); } } - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "gpList : " + gpList.Count + ",gp共有 :" + +gpMessCount); - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "bdList : " + bdList.Count + ",bd共有 : " + bdMessCount); - + if ((gpList.Count > 0 && gpList.Count == gpMessCount) && (bdList.Count > 0) && bdList.Count == bdMessCount) { if (!drawed) @@ -412,8 +407,7 @@ { lock (obj) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "更新更新更新更新更新画:::: : "); - + panelSite.Refresh(); } diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 描述/端口 - Label colDevPort = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "描述", - Location = new Point(242, 0), - Size = new Size(50, 50) - }; - dataGridView_CounterResult.Controls.Add(colDevPort); - colDevPort.BringToFront(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px dataGridView_CounterResult.Columns[0].Width = 50; - dataGridView_CounterResult.Columns[1].Width = 95; - dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[3].Width = 50; - dataGridView_CounterResult.Columns[4].Width = 85; - dataGridView_CounterResult.Columns[5].Width = 105; - dataGridView_CounterResult.Columns[6].Width = 85; - dataGridView_CounterResult.Columns[7].Width = 129; + dataGridView_CounterResult.Columns[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index 09d1e4a..5fd129f 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -31,6 +31,9 @@ { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -73,7 +76,8 @@ this.pic_stability_1 = new System.Windows.Forms.PictureBox(); this.pic_accuracy_1 = new System.Windows.Forms.PictureBox(); this.pic_bootFeature_1 = new System.Windows.Forms.PictureBox(); - this.dataGridView_Channel = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel_old = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel = new Casic.Birmm.RbFreqStandMeasure.MyDataGridView(); this.panel_toTestDev.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tableToBeTested)).BeginInit(); this.panelBase.SuspendLayout(); @@ -103,6 +107,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).BeginInit(); this.SuspendLayout(); // @@ -299,6 +304,7 @@ this.panel_channelList.Controls.Add(this.panel2); this.panel_channelList.Controls.Add(this.panel1); this.panel_channelList.Controls.Add(this.dataGridView_Channel); + this.panel_channelList.Controls.Add(this.dataGridView_Channel_old); this.panel_channelList.Location = new System.Drawing.Point(11, 227); this.panel_channelList.Name = "panel_channelList"; this.panel_channelList.Size = new System.Drawing.Size(1004, 420); @@ -569,6 +575,56 @@ this.pic_bootFeature_1.TabIndex = 319; this.pic_bootFeature_1.TabStop = false; // + // dataGridView_Channel_old + // + this.dataGridView_Channel_old.AllowUserToAddRows = false; + this.dataGridView_Channel_old.AllowUserToDeleteRows = false; + this.dataGridView_Channel_old.AllowUserToResizeColumns = false; + this.dataGridView_Channel_old.AllowUserToResizeRows = false; + dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6; + this.dataGridView_Channel_old.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView_Channel_old.BackgroundColor = System.Drawing.Color.White; + this.dataGridView_Channel_old.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dataGridView_Channel_old.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SunkenHorizontal; + this.dataGridView_Channel_old.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable; + this.dataGridView_Channel_old.ColumnHeadersHeight = 30; + this.dataGridView_Channel_old.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Channel_old.DefaultCellStyle = dataGridViewCellStyle7; + this.dataGridView_Channel_old.GridColor = System.Drawing.Color.DarkGray; + this.dataGridView_Channel_old.Location = new System.Drawing.Point(11, 10); + this.dataGridView_Channel_old.Margin = new System.Windows.Forms.Padding(0); + this.dataGridView_Channel_old.MultiSelect = false; + this.dataGridView_Channel_old.Name = "dataGridView_Channel_old"; + this.dataGridView_Channel_old.RowHeadersVisible = false; + this.dataGridView_Channel_old.RowHeadersWidth = 30; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.RowsDefaultCellStyle = dataGridViewCellStyle8; + this.dataGridView_Channel_old.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.Transparent; + this.dataGridView_Channel_old.RowTemplate.Height = 74; + this.dataGridView_Channel_old.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.dataGridView_Channel_old.Size = new System.Drawing.Size(984, 400); + this.dataGridView_Channel_old.TabIndex = 0; + this.dataGridView_Channel_old.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); + this.dataGridView_Channel_old.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + // // dataGridView_Channel // this.dataGridView_Channel.AllowUserToAddRows = false; @@ -577,7 +633,7 @@ this.dataGridView_Channel.AllowUserToResizeRows = false; dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -606,7 +662,7 @@ this.dataGridView_Channel.RowHeadersWidth = 30; dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -615,9 +671,9 @@ this.dataGridView_Channel.RowTemplate.Height = 74; this.dataGridView_Channel.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dataGridView_Channel.Size = new System.Drawing.Size(984, 400); - this.dataGridView_Channel.TabIndex = 0; - this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); - this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + this.dataGridView_Channel.TabIndex = 342; + this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick_1); + this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint_1); // // HomeCtrlForm // @@ -661,6 +717,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).EndInit(); this.ResumeLayout(false); @@ -679,7 +736,7 @@ private System.Windows.Forms.Button btnPre; private System.Windows.Forms.TextBox textBoxPage; private System.Windows.Forms.Button btnNext; - private System.Windows.Forms.DataGridView dataGridView_Channel; + private System.Windows.Forms.DataGridView dataGridView_Channel_old; private System.Windows.Forms.Label labelNodata; private System.Windows.Forms.PictureBox pic_accuracy_1; private System.Windows.Forms.PictureBox pic_ageRate_1; @@ -708,5 +765,6 @@ private System.Windows.Forms.Panel panel3; public System.Windows.Forms.Label label_receiverStatus; public System.Windows.Forms.Label label_clockStatus; + private MyDataGridView dataGridView_Channel; } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index ca3181d..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,335 +305,354 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + lock (obj) { - channelFreeList.Remove(device.Channel); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } + } } - } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { try { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); - channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else - { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); - } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[12].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; } catch (Exception ex) { @@ -646,23 +665,41 @@ { try { - dataGridView_Channel.ClearSelection(); + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - } - else - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + dataGridView_Channel.ClearSelection(); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); + int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); + if (channelFreeList.Contains(channelNo + "")) + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -729,26 +766,50 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else @@ -773,7 +834,51 @@ channelDlg.ShowDialog(); } - - + private void dataGridView_Channel_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) + { + cellDoubleClick(e.RowIndex); + } + + private void dataGridView_Channel_RowPostPaint_1(object sender, DataGridViewRowPostPaintEventArgs e) + { + try + { + lock (obj) + { + dataGridView_Channel.ClearSelection(); + + int channelNo = e.RowIndex + 1; + + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + + } + } } } diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index f99f106..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -47,6 +47,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); int channel = 0; + public Action HideMaskAction { @@ -66,9 +67,7 @@ SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 - CheckForIllegalCrossThreadCalls = false; - - + CheckForIllegalCrossThreadCalls = false; } private void btnExitChannel_Click(object sender, EventArgs e) @@ -158,6 +157,10 @@ MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -165,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1a82d85..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -30,6 +30,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); DeviceService deviceService = new DeviceServiceImpl(); + #region 无边框拖动效果/最小化窗口/关闭窗口 [DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); @@ -66,6 +67,7 @@ // 跨线程访问控件 CheckForIllegalCrossThreadCalls = false; + } // 开始检测 @@ -117,6 +119,10 @@ MessageBox.Show("无法打开串口" + portName + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -124,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index ed117e0..46d4778 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -47,7 +47,6 @@ public long deviceId = -1; public static bool isInDetection = false; - public Action HideMaskAction { get; @@ -77,7 +76,8 @@ text_channelNo.WatermarkText = "无空闲通道"; groupBox1.Enabled = false; } - + + } // 关闭对话框 @@ -208,6 +208,10 @@ MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -217,7 +221,7 @@ try { - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); return; diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index e0c40b6..ad05a32 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -337,7 +337,12 @@ groupBox3.Text = "1s频率稳定度"; stability result = new stability(); result.label_stability.Text = ""; - if (!resultStaStr1.Equals("-1")&& !resultStaStr1.Equals("-2")&&!resultStaStr1.Equals("-3")) result.label_stability.Text = resultStaStr1; + result.label_count.Text = ""; + if (!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3")) + { + result.label_stability.Text = resultStaStr1; + result.label_count.Text = "101"; + } result.Show(); panel_result.Controls.Add(result); diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 19e2f83..cfb23dd 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -133,7 +133,7 @@ } DetectionHelper detectionHelper = new DetectionHelper(); - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNoReDetec + "]!"); btn_reDetec.Enabled = true; diff --git a/RbFreqStandMeasure/info/stability.designer.cs b/RbFreqStandMeasure/info/stability.designer.cs index e9dc1c9..40caec5 100644 --- a/RbFreqStandMeasure/info/stability.designer.cs +++ b/RbFreqStandMeasure/info/stability.designer.cs @@ -44,7 +44,6 @@ this.label_count.Name = "label_count"; this.label_count.Size = new System.Drawing.Size(83, 27); this.label_count.TabIndex = 82; - this.label_count.Text = "101"; this.label_count.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // label_stability @@ -98,9 +97,9 @@ } #endregion - private System.Windows.Forms.Label label_count; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label9; public System.Windows.Forms.Label label_stability; + public System.Windows.Forms.Label label_count; } } diff --git a/RbFreqStandMeasure/status/StatusCtrlForm.cs b/RbFreqStandMeasure/status/StatusCtrlForm.cs index 44a5302..8a7853d 100644 --- a/RbFreqStandMeasure/status/StatusCtrlForm.cs +++ b/RbFreqStandMeasure/status/StatusCtrlForm.cs @@ -137,8 +137,7 @@ { if ((i + 3) < arr.Length && !arr[i + 1].Equals("") && !arr[i + 2].Equals("") && !arr[i + 3].Equals("")) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, arr[i + 1] + ";" + arr[i + 2] + ";" + arr[i + 3]); - + int Elevation = Convert.ToInt32(arr[i + 1]); int azimuth = Convert.ToInt32(arr[i + 2]); double cosLen = Math.Cos(Elevation * Math.PI / 180) * (575 / 2); @@ -168,8 +167,7 @@ { if ((i + 3) < arr.Length && !arr[i + 1].Equals("") && !arr[i + 2].Equals("") && !arr[i + 3].Equals("")) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, arr[i + 1] + ";" + arr[i + 2] + ";" + arr[i + 3]); - + int Elevation = Convert.ToInt32(arr[i + 1]); int azimuth = Convert.ToInt32(arr[i + 2]); double cosLen = Math.Cos(Elevation * Math.PI / 180) * (575 / 2); @@ -258,7 +256,7 @@ if (!portSatellite.IsOpen) portSatellite.Open(); if (portSatellite.IsOpen) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "打开串口成功!" + portName); + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "打开卫星状态串口成功!" + portName); } else { @@ -379,7 +377,6 @@ } else if ((sss.Contains("GPGSV") || sss.Contains("BDGSV") || sss.Contains("GBGSV")) && sss.Contains("*")) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "GSV : " + sss); if (sss.Split(',').Length > 8) { if (sss.Contains("GPGSV")) @@ -400,9 +397,7 @@ totalBD = Convert.ToInt32(sss.Split(',')[3]); } } - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "gpList : " + gpList.Count + ",gp共有 :" + +gpMessCount); - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "bdList : " + bdList.Count + ",bd共有 : " + bdMessCount); - + if ((gpList.Count > 0 && gpList.Count == gpMessCount) && (bdList.Count > 0) && bdList.Count == bdMessCount) { if (!drawed) @@ -412,8 +407,7 @@ { lock (obj) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "更新更新更新更新更新画:::: : "); - + panelSite.Refresh(); } diff --git a/RbFreqStandMeasure/tools/DetectionHelper.cs b/RbFreqStandMeasure/tools/DetectionHelper.cs index 6796778..2070bac 100644 --- a/RbFreqStandMeasure/tools/DetectionHelper.cs +++ b/RbFreqStandMeasure/tools/DetectionHelper.cs @@ -84,6 +84,8 @@ if (isUpdates) { isUpdate = true; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度 interval =" + interval + ";detectionItemId="+detectionItemId); + } portStability = port; devIdStability = deviceId; @@ -106,26 +108,30 @@ } private void exeStability1(Object State) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取稳定度1s"); try { lock (obj) { lock(resultStability1) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "isStarted:" + isStarted + ", detectionItemId =" + detectionItemId); - - if (!isStarted) + while (true) { - while (true) - { - if (detectionItemId != -1) + if (detectionItemId != -1) + { + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item==null||(item!=null&&Convert.ToDateTime(item.EndTime) < DateTime.Now)) { + timerStability1.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度1s,devId="+ devIdStability+";detectionItemId="+ detectionItemId); + + return; + } + if (!isStarted) + { isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); - detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); - + detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); @@ -134,83 +140,95 @@ if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - break; } + break; } } string result = ""; - string fre = getFrequencyData(portStability); - if (!fre.Equals("") && resultStability1.Count<101) + string fre = getFrequencyData(portStability,false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,稳定度1s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability1.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "0", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } + if (!fre.Equals("") && resultStability1.Count<101) + { + resultStability1.Add(fre); + if (resultStability1.Count == 101) timerStability1.Dispose(); + if (!isUpdate && count1s < 101) { - resultStability1.Add(fre); - if (resultStability1.Count == 101) timerStability1.Dispose(); - if (!isUpdate && count1s < 101) - { - detectionService.add(devIdStability, fre, "1-1",detectionItemId); - count1s++; - } - } - if (!isUpdate) - { - if (resultStability1.Count == 101) - { - result = FreMath.Stable(resultStability1) + ""; - resultStability1.Clear(); - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "1s稳定度结果:" + result + ", devId =" + devIdStability); - - // 更新检测结果 - detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result, "", "", ""); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detectionId :" + detectionItemId); - - DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); - if (detectionItem != null) - { - //更新稳定度检测状态 - if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) - { - detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); - - } - detectionItem = detectionItemService.searchById(detectionItemId); - //更新整个仪器检测状态 - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); - } - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - } - - } + detectionService.add(devIdStability, fre, "1-1",detectionItemId); + count1s++; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,1s稳定度,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); } - else + } + if (!isUpdate) + { + if (resultStability1.Count == 101) + { + result = FreMath.Stable(resultStability1) + ""; + resultStability1.Clear(); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "1s稳定度测量结果:" + result + ", devId =" + devIdStability + ";detectionItemId=" + detectionItemId); + + // 更新检测结果 + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result, "", "", ""); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detectionId :" + detectionItemId); + + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) + { + //更新稳定度检测状态 + if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) + { + detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + + } + detectionItem = detectionItemService.searchById(detectionItemId); + //更新整个仪器检测状态 + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) + { + deviceService.updateStatus(devIdStability, "3", ""); + } + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + } + + } + } + else + { + if (resultStability1.Count == 101) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度1s"); - if (resultStability1.Count == 101) - { - timerStability1.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度1s得到结果,detectionItemId="+ detectionItemId); - string result1 = FreMath.Stable(resultStability1) + ""; - detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result1, "", "", ""); + timerStability1.Dispose(); - updateView(resultStability1); - stability.label_result.Text = result1; + string result1 = FreMath.Stable(resultStability1) + ""; + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result1, "", "", ""); + + updateView(resultStability1); + stability.label_result.Text = result1; DetailDlg.detailDlg.resultStaStr1 = result1; resultStability1.Clear(); } - } - } + } + } } } catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度检测错误:" + ex.Message); - - } } @@ -219,12 +237,20 @@ { lock (obj) { - if (!isStarted) + while (true) { - while (true) + if (detectionItemId != -1) { - if (detectionItemId != -1) + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item == null || (item != null && Convert.ToDateTime(item.EndTime) < DateTime.Now)) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度10s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability10.Dispose(); + return; + } + if (!isStarted) + { isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); @@ -236,15 +262,30 @@ if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - break; + } + break; } } string result = ""; - string fre = getFrequencyData(portStability); + string fre = getFrequencyData(portStability, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,稳定度10s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability10.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "0", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } + if (!fre.Equals("") && resultStability10.Count < 101) { resultStability10.Add(fre); @@ -253,17 +294,18 @@ { detectionService.add(devIdStability, fre, "1-10", detectionItemId); count10s++; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,10s稳定度,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + } - } - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度10s fre=" + fre + ", devId =" + devIdStability); + } + if (!isUpdate) { if (resultStability10.Count == 101) { timerStability10.Dispose(); result = FreMath.Stable(resultStability10) + ""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "10s稳定度检测结果:" + result +", devId =" + devIdStability); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "10s稳定度检测结果:" + result +", devId =" + devIdStability + ";detectionItemId=" + detectionItemId); detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", result, "", ""); @@ -282,7 +324,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); @@ -293,6 +334,8 @@ { if (resultStability10.Count == 101) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度10s得到结果,detectionItemId=" + detectionItemId); + timerStability10.Dispose(); @@ -312,12 +355,20 @@ { lock (obj) { - if (!isStarted) + while (true) { - while (true) + if (detectionItemId != -1) { - if (detectionItemId != -1) + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item == null || (item != null && Convert.ToDateTime(item.EndTime) < DateTime.Now)) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度20s, devId = " + devIdStability + "; detectionItemId = " + detectionItemId); + + timerStability20.Dispose(); + return; + } + if (!isStarted) + { isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); @@ -329,14 +380,28 @@ if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - break; + } + break; } } string result = ""; - string fre = getFrequencyData(portStability); + string fre = getFrequencyData(portStability, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,稳定度20s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability20.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "0", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (!fre.Equals("") && resultStability20.Count < 101) { resultStability20.Add(fre); @@ -344,11 +409,12 @@ { detectionService.add(devIdStability, fre, "1-20", detectionItemId); count20s++; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,20s稳定度,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + } } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度20s fre=" + fre + ", devId =" + devIdStability); - + if (!isUpdate) { if (resultStability20.Count == 101) @@ -356,7 +422,7 @@ timerStability20.Dispose(); result = FreMath.Stable(resultStability20) + ""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "20s稳定度检测结果:" + result + ", devId =" + devIdStability); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "20s稳定度检测结果:" + result + ", devId =" + devIdStability + ";detectionItemId=" + detectionItemId); detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", result, ""); @@ -375,7 +441,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); @@ -389,6 +454,8 @@ { if (resultStability20.Count == 101) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度20s得到结果,detectionItemId=" + detectionItemId); + timerStability20.Dispose(); @@ -414,6 +481,15 @@ { while (true) { + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item == null || (item != null && Convert.ToDateTime(item.EndTime) < DateTime.Now)) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度100s, devId = " + devIdStability + "; detectionItemId = " + detectionItemId); + + timerStability100.Dispose(); + return; + } + if (detectionItemId != -1) { isStarted = true; @@ -427,21 +503,39 @@ if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - break; + } + break; } } string result = ""; - string fre = getFrequencyData(portStability); + string fre = getFrequencyData(portStability, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,稳定度100s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability100.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", "0"); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (!fre.Equals("") && resultStability100.Count < 101) { resultStability100.Add(fre); - if (!isUpdate) detectionService.add(devIdStability, fre, "1-100", detectionItemId); - } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度100s fre=" + fre + ", devId =" + devIdStability); + if (!isUpdate) + { + detectionService.add(devIdStability, fre, "1-100", detectionItemId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,100s稳定度,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + } + } + if (!isUpdate) { @@ -450,7 +544,7 @@ timerStability100.Dispose(); result = FreMath.Stable(resultStability100) + ""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "100s稳定度检测结果:" + result + ", devId =" + devIdStability); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "100s稳定度检测结果:" + result + ", devId =" + devIdStability + ";detectionItemId=" + detectionItemId); detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", result); @@ -469,7 +563,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); } @@ -480,6 +573,8 @@ { if (resultStability100.Count == 101) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度100s得到结果,detectionItemId=" + detectionItemId); + timerStability100.Dispose(); string result1 = FreMath.Stable(resultStability100) + ""; @@ -514,57 +609,77 @@ TimeSpan secondSpan = new TimeSpan(Convert.ToDateTime(endTime).Ticks - DateTime.Now.Ticks); delay = (int)secondSpan.TotalMilliseconds - 20*1000; } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "准确度 endtime:"+endTime + "; delay:"+delay); - + timerAccuracy = new System.Threading.Timer(exeAccuracy, null, delay + 200 ,5*60*1000); } private void exeAccuracy(Object State) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "哈哈哈哈,检测准确度了!!!!!!!"+DateTime.Now.ToLongTimeString()); - + { try { lock (obj) { - if (!isStarted) + while (true) { - while (true) + if (detectionItemId != -1) { - if (detectionItemId != -1) + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item == null || (item != null && Convert.ToDateTime(item.EndTime) < DateTime.Now)) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,准确度, devId=" + devIdAccuracy + ";detectionItemId=" + detectionItemId); + + timerAccuracy.Dispose(); + return; + } + if (!isStarted) + { + isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); - if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); - if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); - if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); - if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); - if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); + if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); + if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); if (detectionItem0.Accuracy.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "-1", "", "", "", "", "", "", ""); if (detectionItem0.BootFeature.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "-1", "", "", "", "", "", ""); if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - break; + } + break; } } - if (isUpdate) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测准确度!!!!!!!开始"); string result = ""; double sum = 0.0; List resultList = new List(); for (int i = 0; i < 500; i++) { - string fre = getFrequencyData(portAccuracy); + string fre = getFrequencyData(portAccuracy, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,准确度,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerAccuracy.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (fre.Equals("")) continue; resultList.Add(fre); if (!isUpdate) { detectionService.add(devIdAccuracy, fre, "2", detectionItemId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,准确度, devId=" + devIdAccuracy + ";detectionItemId=" + detectionItemId); + } - if (resultList.Count == 3) + if (resultList.Count == 3) { sum = sum + Convert.ToDouble(fre); break; @@ -584,20 +699,21 @@ } if (!isUpdate) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "准确度检测结果result="+result+",detectionItemId=" + detectionItemId); + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); if (detectionItem != null) { if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdAccuracy, "3", ""); - portAccuracy.Close(); } } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); } else { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新label_result:" + result); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测准确度得到结果,detectionItemId=" + detectionItemId); accuracy.label_result.Text = result; DetailDlg.detailDlg.resultAccStr = result; @@ -638,7 +754,14 @@ lock (obj) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "isStarted:"+ isStarted); + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item == null || (item != null && Convert.ToDateTime(item.EndTime) < DateTime.Now)) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,开机特性, devId=" + devIdAccuracy + ";detectionItemId=" + detectionItemId); + timerBootFeature.Dispose(); + return; + } if (!isStarted) { while (true) @@ -649,11 +772,11 @@ { isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); - if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); - if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); - if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); - if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); - if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); + if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); + if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); if (detectionItem0.Accuracy.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "-1", "", "", "", "", "", "", ""); if (detectionItem0.BootFeature.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "-1", "", "", "", "", "", ""); if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); @@ -664,22 +787,36 @@ } } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测开机特性"); - + string result = ""; double sum = 0.0; int count = 0; for (int i = 0; i < 50; i++) { - string fre = getFrequencyData(portBootFeature); + string fre = getFrequencyData(portBootFeature, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,开机特性,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerBootFeature.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (!fre.Equals("")) { count++; sum = sum + Convert.ToDouble(fre); + if (count == 3) break; } } detectionService.add(devIdBootFeature, sum / 3 + "", "3", detectionItemId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,开机特性, devId=" + devIdAccuracy + ";detectionItemId=" + detectionItemId); + resultBootFeature.Add(sum / 3 + ""); if (resultBootFeature.Count == 8) @@ -693,6 +830,7 @@ if (Convert.ToDouble(fre) < Convert.ToDouble(min) || min.Equals("0.0")) min = fre; } result = (Convert.ToDouble(max) - Convert.ToDouble(min)) + ""; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开机特性检测结果result=" + result + ",detectionItemId=" + detectionItemId); detectionItemService.updateDetecStatus(detectionItemId, "", "", result, "", "", "", "", "", ""); @@ -702,7 +840,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdBootFeature, "3", ""); - portBootFeature.Close(); } } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); @@ -736,26 +873,36 @@ { lock (obj) { - if (!isStarted) + while (true) { - while (true) + if (detectionItemId != -1) { - if (detectionItemId != -1) + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item == null || (item != null && Convert.ToDateTime(item.EndTime) < DateTime.Now)) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,日老化率, devId=" + devIdAccuracy + ";detectionItemId=" + detectionItemId); + + timerAgeRate.Dispose(); + return; + } + if (!isStarted) + { + isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); - if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); - if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); - if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); - if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); - if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); + if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); + if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); if (detectionItem0.Accuracy.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "-1", "", "", "", "", "", "", ""); if (detectionItem0.BootFeature.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "-1", "", "", "", "", "", ""); if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - break; + } + break; } } @@ -766,15 +913,30 @@ int count = 0; for (int i = 0; i < 50; i++) { - string fre = getFrequencyData(portAgeRate); + string fre = getFrequencyData(portAgeRate, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,日老化率,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerAgeRate.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (!fre.Equals("")) { count++; sum = sum + Convert.ToDouble(fre); + if (count == 3) break; } } detectionService.add(devIdAgeRate, sum / 3+"", "4", detectionItemId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,日老化率, devId=" + devIdAccuracy + ";detectionItemId=" + detectionItemId); + resultAgeRate.Add(sum / 3 + ""); if (resultAgeRate.Count == 15) @@ -783,7 +945,7 @@ double r = 0.0; double k = FreMath.DriftRate(resultAgeRate, out r); result = k + "," + r.ToString().Substring(0,5); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "日老化率检测结果:" + result); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "日老化率检测结果result=" + result + ",detectionItemId=" + detectionItemId); detectionItemService.updateDetecStatus(detectionItemId, "", "", "", result, "", "", "", "", ""); @@ -793,7 +955,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdAgeRate, "3", ""); - portAgeRate.Close(); } } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); @@ -808,7 +969,7 @@ // 获取检测数据 - public string getFrequencyData(SerialPort port) + public string getFrequencyData(SerialPort port, bool isTest) { string received = ""; try @@ -818,15 +979,20 @@ if (!isUsing) { isUsing = true; - if (port.IsOpen) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "portname:" + port.PortName); - else LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, port.PortName + " port closed"); + if (!port.IsOpen) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, port.PortName + " closed!!!!!!"); + string name = ConfigHelper.getKeyByValue(port.PortName + " 115200").Replace("channel", "通道"); + MessageBox.Show(name+"的端口异常关闭,该通道上的检测将终止!"); + return "close"; + } if (ConfigHelper.GetAppConfig("deviceType").ToString().Equals("1")) { int count = 0; while (count < 600) { - Thread.Sleep(100); + int readLen = port.BytesToRead; if (readLen > 0) { @@ -855,6 +1021,7 @@ } } count++; + Thread.Sleep(100); } } else @@ -863,7 +1030,7 @@ while (count < 600) { - Thread.Sleep(100); + int readLen = port.BytesToRead; if (readLen > 0) { @@ -889,6 +1056,8 @@ } } count++; + + Thread.Sleep(100); } } @@ -896,7 +1065,14 @@ if (received.Equals("")) { string name = ConfigHelper.getKeyByValue(port.PortName + " 115200").Replace("channel", "通道"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, name + "获取数据失败!" + DateTime.Now.ToLongTimeString()); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, name + "获取数据失败!!!!!!!!!!!!!!" + DateTime.Now.ToLongTimeString()); + if (!isTest) + { + MessageBox.Show("从[" + name + "]获取数据失败,该通道上的检测将终止!"); + return "close"; + } + + return received; } break; } @@ -917,16 +1093,12 @@ } private void updateView(List result) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始更新界面 length:"+ result.Count); - + { isUpdate = false; //new Thread(() => //{ int index = 0; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "DetailDlg.dataGridView.Rows:" + DetailDlg.dataGridView.Rows); - - + foreach (DataGridViewRow row in DetailDlg.dataGridView.Rows) { if (index < result.Count) diff --git a/RbFreqStandMeasure/MyDataGridView.Designer.cs b/RbFreqStandMeasure/MyDataGridView.Designer.cs new file mode 100644 index 0000000..f69392d --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.Designer.cs @@ -0,0 +1,36 @@ +namespace Casic.Birmm.RbFreqStandMeasure +{ + partial class MyDataGridView + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/RbFreqStandMeasure/MyDataGridView.cs b/RbFreqStandMeasure/MyDataGridView.cs new file mode 100644 index 0000000..3f1fd6f --- /dev/null +++ b/RbFreqStandMeasure/MyDataGridView.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Casic.Birmm.RbFreqStandMeasure.Tools; +using System.Reflection; + +namespace Casic.Birmm.RbFreqStandMeasure +{ + public partial class MyDataGridView : DataGridView + { + public MyDataGridView() + { + InitializeComponent(); + } + protected override void OnPaint(PaintEventArgs e) + { + try + { + base.OnPaint(e); + } + catch(Exception ex) + { + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "重绘通道列表出错:" + ex.Message); + + Invalidate(); + } + } + } +} diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,10 +15,11 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs index dd7aa0e..6fd244e 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DeviceService.cs @@ -28,7 +28,7 @@ List getDeviceByChannel(); List getAllCounter(); - + int clearChannel(); } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -82,7 +82,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -110,7 +110,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update: " + e.Message); iRetval = -1; } return iRetval; @@ -123,7 +123,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -159,7 +159,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "startDetect: " + e.Message); iRetval = -1; } @@ -174,7 +174,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -205,8 +205,7 @@ sQry = sQry + " STABILITY_100=@STABILITY_100,"; sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); - + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; @@ -225,7 +224,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetecStatus: " + e.Message); iRetval = -1; } @@ -240,7 +239,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -263,7 +262,7 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem CHANNEL: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateChannelNo CHANNEL: " + e.Message); iRetval = -1; } @@ -277,7 +276,7 @@ { if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection : 数据库链接断开"); iRetval = DbConnectService.openDb(); if (iRetval != 0) { @@ -294,7 +293,6 @@ if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -316,11 +314,62 @@ } catch (MySqlException e) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stopDetection: " + e.Message); iRetval = -1; } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = null; + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getById: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { @@ -378,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2de0df9..2fc89ad 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,52 +481,78 @@ string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); - - using (MySqlDataReader aReader = aCommand.ExecuteReader()) + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) { - while (aReader.Read()) - { - DeviceView deviceView = new DeviceView(); - - if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id - if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName - if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode - if (!aReader.IsDBNull(3)) - { - deviceView.DevTypeId = aReader.GetString(3); // devType - //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); - } - if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel - if (!aReader.IsDBNull(5)) - { - DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName - if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev - if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); - if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); - if (!aReader.IsDBNull(10)) - { - DateTime reg = aReader.GetDateTime(10); // regTime - deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(11)) - { - DateTime reg = aReader.GetDateTime(11); // regTime - deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); - } - if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); - if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); - if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); - if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + DeviceView deviceView = new DeviceView(); + if(dt.Rows[0][0] != DBNull.Value) deviceView.Id = Convert.ToInt64(dt.Rows[0][0]); + if (dt.Rows[0][1] != DBNull.Value) deviceView.DevName = dt.Rows[0][1].ToString(); + if (dt.Rows[0][2] != DBNull.Value) deviceView.DevCode = dt.Rows[0][2].ToString(); + if (dt.Rows[0][3] != DBNull.Value) deviceView.DevTypeId = dt.Rows[0][3].ToString(); + if (dt.Rows[0][4] != DBNull.Value) deviceView.DevModel = dt.Rows[0][4].ToString(); + if (dt.Rows[0][5] != DBNull.Value) deviceView.RegTime = dt.Rows[0][5].ToString(); + if (dt.Rows[0][6] != DBNull.Value) deviceView.CustomerName = dt.Rows[0][6].ToString(); + if (dt.Rows[0][7] != DBNull.Value) deviceView.CustomerDev = dt.Rows[0][7].ToString(); + if (dt.Rows[0][8] != DBNull.Value) deviceView.Channel = dt.Rows[0][8].ToString(); + if (dt.Rows[0][9] != DBNull.Value) deviceView.Active = Convert.ToInt32(dt.Rows[0][9]); + if (dt.Rows[0][10] != DBNull.Value) deviceView.StartTime = Convert.ToDateTime(dt.Rows[0][10]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][11] != DBNull.Value) deviceView.EndTime = Convert.ToDateTime(dt.Rows[0][11]).ToString("yyyy - MM - dd HH: mm:ss"); + if (dt.Rows[0][12] != DBNull.Value) deviceView.StatusId = dt.Rows[0][12].ToString(); + if (dt.Rows[0][13] != DBNull.Value) deviceView.Stability = dt.Rows[0][13].ToString(); + if (dt.Rows[0][14] != DBNull.Value) deviceView.Accuracy = dt.Rows[0][14].ToString(); + if (dt.Rows[0][15] != DBNull.Value) deviceView.BootFeature = dt.Rows[0][15].ToString(); + if (dt.Rows[0][16] != DBNull.Value) deviceView.AgeRate = dt.Rows[0][16].ToString(); + if (dt.Rows[0][17] != DBNull.Value) deviceView.DetectionItemId = Convert.ToInt64(dt.Rows[0][17]); - deviceViewList.Add(deviceView); - - aCommand.Dispose(); - } } + //using (MySqlDataReader aReader = aCommand.ExecuteReader()) + //{ + // while (aReader.Read()) + // { + // DeviceView deviceView = new DeviceView(); + + // if (!aReader.IsDBNull(0)) deviceView.Id = Convert.ToInt64(aReader.GetString(0)); // id + // if (!aReader.IsDBNull(1)) deviceView.DevName = aReader.GetString(1); // devName + // if (!aReader.IsDBNull(2)) deviceView.DevCode = aReader.GetString(2); // devCode + // if (!aReader.IsDBNull(3)) + // { + // deviceView.DevTypeId = aReader.GetString(3); // devType + // //deviceView.DevTypeName = dictService.getNameByCode("devType", aReader.GetString(3)); + // } + // if (!aReader.IsDBNull(4)) deviceView.DevModel = aReader.GetString(4); // devModel + // if (!aReader.IsDBNull(5)) + // { + // DateTime reg = aReader.GetDateTime(5); // regTime + // deviceView.RegTime = reg.ToString("yyyy-MM-dd"); + // } + // if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName + // if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev + // if (!aReader.IsDBNull(8)) deviceView.Channel = aReader.GetString(8); + // if (!aReader.IsDBNull(9)) deviceView.Active = Convert.ToInt32(aReader.GetString(9)); + // if (!aReader.IsDBNull(10)) + // { + // DateTime reg = aReader.GetDateTime(10); // regTime + // deviceView.StartTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(11)) + // { + // DateTime reg = aReader.GetDateTime(11); // regTime + // deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + // } + // if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); + // if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); + // if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); + // if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); + // if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); + // if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); + + // deviceViewList.Add(deviceView); + + // aCommand.Dispose(); + // } + //} if (deviceViewList.Count > 0) { @@ -584,5 +610,42 @@ return iRetval; } + public int clearChannel() + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + string sQry = "UPDATE r_device SET CHANNEL=''"; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + sQry = "UPDATE r_device SET STATUSID='1' WHERE STATUSID='2'"; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + + iRetval = 0; + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "clearChannel : " + ex.Message); + } + return iRetval; + } + + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/RbFreqStandMeasure.csproj b/RbFreqStandMeasure/RbFreqStandMeasure.csproj index c1d76b7..1455bc9 100644 --- a/RbFreqStandMeasure/RbFreqStandMeasure.csproj +++ b/RbFreqStandMeasure/RbFreqStandMeasure.csproj @@ -239,6 +239,12 @@ accuracy.cs + + Component + + + MyDataGridView.cs + True True diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index a3daf40..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -362,7 +363,25 @@ detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); } } - } + deviceService.clearChannel(); + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 39366fc..1d3a64b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 描述/端口 - Label colDevPort = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "描述", - Location = new Point(242, 0), - Size = new Size(50, 50) - }; - dataGridView_CounterResult.Controls.Add(colDevPort); - colDevPort.BringToFront(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px dataGridView_CounterResult.Columns[0].Width = 50; - dataGridView_CounterResult.Columns[1].Width = 95; - dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[3].Width = 50; - dataGridView_CounterResult.Columns[4].Width = 85; - dataGridView_CounterResult.Columns[5].Width = 105; - dataGridView_CounterResult.Columns[6].Width = 85; - dataGridView_CounterResult.Columns[7].Width = 129; + dataGridView_CounterResult.Columns[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index 09d1e4a..5fd129f 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -31,6 +31,9 @@ { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); @@ -73,7 +76,8 @@ this.pic_stability_1 = new System.Windows.Forms.PictureBox(); this.pic_accuracy_1 = new System.Windows.Forms.PictureBox(); this.pic_bootFeature_1 = new System.Windows.Forms.PictureBox(); - this.dataGridView_Channel = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel_old = new System.Windows.Forms.DataGridView(); + this.dataGridView_Channel = new Casic.Birmm.RbFreqStandMeasure.MyDataGridView(); this.panel_toTestDev.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tableToBeTested)).BeginInit(); this.panelBase.SuspendLayout(); @@ -103,6 +107,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).BeginInit(); this.SuspendLayout(); // @@ -299,6 +304,7 @@ this.panel_channelList.Controls.Add(this.panel2); this.panel_channelList.Controls.Add(this.panel1); this.panel_channelList.Controls.Add(this.dataGridView_Channel); + this.panel_channelList.Controls.Add(this.dataGridView_Channel_old); this.panel_channelList.Location = new System.Drawing.Point(11, 227); this.panel_channelList.Name = "panel_channelList"; this.panel_channelList.Size = new System.Drawing.Size(1004, 420); @@ -569,6 +575,56 @@ this.pic_bootFeature_1.TabIndex = 319; this.pic_bootFeature_1.TabStop = false; // + // dataGridView_Channel_old + // + this.dataGridView_Channel_old.AllowUserToAddRows = false; + this.dataGridView_Channel_old.AllowUserToDeleteRows = false; + this.dataGridView_Channel_old.AllowUserToResizeColumns = false; + this.dataGridView_Channel_old.AllowUserToResizeRows = false; + dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6; + this.dataGridView_Channel_old.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView_Channel_old.BackgroundColor = System.Drawing.Color.White; + this.dataGridView_Channel_old.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.dataGridView_Channel_old.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SunkenHorizontal; + this.dataGridView_Channel_old.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.Disable; + this.dataGridView_Channel_old.ColumnHeadersHeight = 30; + this.dataGridView_Channel_old.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Channel_old.DefaultCellStyle = dataGridViewCellStyle7; + this.dataGridView_Channel_old.GridColor = System.Drawing.Color.DarkGray; + this.dataGridView_Channel_old.Location = new System.Drawing.Point(11, 10); + this.dataGridView_Channel_old.Margin = new System.Windows.Forms.Padding(0); + this.dataGridView_Channel_old.MultiSelect = false; + this.dataGridView_Channel_old.Name = "dataGridView_Channel_old"; + this.dataGridView_Channel_old.RowHeadersVisible = false; + this.dataGridView_Channel_old.RowHeadersWidth = 30; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.dataGridView_Channel_old.RowsDefaultCellStyle = dataGridViewCellStyle8; + this.dataGridView_Channel_old.RowTemplate.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.Transparent; + this.dataGridView_Channel_old.RowTemplate.Height = 74; + this.dataGridView_Channel_old.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; + this.dataGridView_Channel_old.Size = new System.Drawing.Size(984, 400); + this.dataGridView_Channel_old.TabIndex = 0; + this.dataGridView_Channel_old.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); + this.dataGridView_Channel_old.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + // // dataGridView_Channel // this.dataGridView_Channel.AllowUserToAddRows = false; @@ -577,7 +633,7 @@ this.dataGridView_Channel.AllowUserToResizeRows = false; dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -606,7 +662,7 @@ this.dataGridView_Channel.RowHeadersWidth = 30; dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(203)))), ((int)(((byte)(208))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Transparent; dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); @@ -615,9 +671,9 @@ this.dataGridView_Channel.RowTemplate.Height = 74; this.dataGridView_Channel.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dataGridView_Channel.Size = new System.Drawing.Size(984, 400); - this.dataGridView_Channel.TabIndex = 0; - this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick); - this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint); + this.dataGridView_Channel.TabIndex = 342; + this.dataGridView_Channel.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Channel_CellDoubleClick_1); + this.dataGridView_Channel.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(this.dataGridView_Channel_RowPostPaint_1); // // HomeCtrlForm // @@ -661,6 +717,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pic_stability_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_accuracy_1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pic_bootFeature_1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel_old)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Channel)).EndInit(); this.ResumeLayout(false); @@ -679,7 +736,7 @@ private System.Windows.Forms.Button btnPre; private System.Windows.Forms.TextBox textBoxPage; private System.Windows.Forms.Button btnNext; - private System.Windows.Forms.DataGridView dataGridView_Channel; + private System.Windows.Forms.DataGridView dataGridView_Channel_old; private System.Windows.Forms.Label labelNodata; private System.Windows.Forms.PictureBox pic_accuracy_1; private System.Windows.Forms.PictureBox pic_ageRate_1; @@ -708,5 +765,6 @@ private System.Windows.Forms.Panel panel3; public System.Windows.Forms.Label label_receiverStatus; public System.Windows.Forms.Label label_clockStatus; + private MyDataGridView dataGridView_Channel; } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index ca3181d..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,335 +305,354 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + lock (obj) { - channelFreeList.Remove(device.Channel); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } + } } - } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { try { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); - channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else - { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); - } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[12].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; } catch (Exception ex) { @@ -646,23 +665,41 @@ { try { - dataGridView_Channel.ClearSelection(); + lock (obj) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - } - else - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + dataGridView_Channel.ClearSelection(); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); + int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); + if (channelFreeList.Contains(channelNo + "")) + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -729,26 +766,50 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else @@ -773,7 +834,51 @@ channelDlg.ShowDialog(); } - - + private void dataGridView_Channel_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) + { + cellDoubleClick(e.RowIndex); + } + + private void dataGridView_Channel_RowPostPaint_1(object sender, DataGridViewRowPostPaintEventArgs e) + { + try + { + lock (obj) + { + dataGridView_Channel.ClearSelection(); + + int channelNo = e.RowIndex + 1; + + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + } + else + { + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + } + foreach (string no in channelFreeList.ToArray()) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } + + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + } + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + + } + } } } diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index f99f106..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -47,6 +47,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); int channel = 0; + public Action HideMaskAction { @@ -66,9 +67,7 @@ SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 - CheckForIllegalCrossThreadCalls = false; - - + CheckForIllegalCrossThreadCalls = false; } private void btnExitChannel_Click(object sender, EventArgs e) @@ -158,6 +157,10 @@ MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -165,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1a82d85..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -30,6 +30,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); DeviceService deviceService = new DeviceServiceImpl(); + #region 无边框拖动效果/最小化窗口/关闭窗口 [DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); @@ -66,6 +67,7 @@ // 跨线程访问控件 CheckForIllegalCrossThreadCalls = false; + } // 开始检测 @@ -117,6 +119,10 @@ MessageBox.Show("无法打开串口" + portName + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -124,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index ed117e0..46d4778 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -47,7 +47,6 @@ public long deviceId = -1; public static bool isInDetection = false; - public Action HideMaskAction { get; @@ -77,7 +76,8 @@ text_channelNo.WatermarkText = "无空闲通道"; groupBox1.Enabled = false; } - + + } // 关闭对话框 @@ -208,6 +208,10 @@ MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { @@ -217,7 +221,7 @@ try { - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); return; diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index e0c40b6..ad05a32 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -337,7 +337,12 @@ groupBox3.Text = "1s频率稳定度"; stability result = new stability(); result.label_stability.Text = ""; - if (!resultStaStr1.Equals("-1")&& !resultStaStr1.Equals("-2")&&!resultStaStr1.Equals("-3")) result.label_stability.Text = resultStaStr1; + result.label_count.Text = ""; + if (!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3")) + { + result.label_stability.Text = resultStaStr1; + result.label_count.Text = "101"; + } result.Show(); panel_result.Controls.Add(result); diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 19e2f83..cfb23dd 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -133,7 +133,7 @@ } DetectionHelper detectionHelper = new DetectionHelper(); - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNoReDetec + "]!"); btn_reDetec.Enabled = true; diff --git a/RbFreqStandMeasure/info/stability.designer.cs b/RbFreqStandMeasure/info/stability.designer.cs index e9dc1c9..40caec5 100644 --- a/RbFreqStandMeasure/info/stability.designer.cs +++ b/RbFreqStandMeasure/info/stability.designer.cs @@ -44,7 +44,6 @@ this.label_count.Name = "label_count"; this.label_count.Size = new System.Drawing.Size(83, 27); this.label_count.TabIndex = 82; - this.label_count.Text = "101"; this.label_count.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // label_stability @@ -98,9 +97,9 @@ } #endregion - private System.Windows.Forms.Label label_count; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label9; public System.Windows.Forms.Label label_stability; + public System.Windows.Forms.Label label_count; } } diff --git a/RbFreqStandMeasure/status/StatusCtrlForm.cs b/RbFreqStandMeasure/status/StatusCtrlForm.cs index 44a5302..8a7853d 100644 --- a/RbFreqStandMeasure/status/StatusCtrlForm.cs +++ b/RbFreqStandMeasure/status/StatusCtrlForm.cs @@ -137,8 +137,7 @@ { if ((i + 3) < arr.Length && !arr[i + 1].Equals("") && !arr[i + 2].Equals("") && !arr[i + 3].Equals("")) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, arr[i + 1] + ";" + arr[i + 2] + ";" + arr[i + 3]); - + int Elevation = Convert.ToInt32(arr[i + 1]); int azimuth = Convert.ToInt32(arr[i + 2]); double cosLen = Math.Cos(Elevation * Math.PI / 180) * (575 / 2); @@ -168,8 +167,7 @@ { if ((i + 3) < arr.Length && !arr[i + 1].Equals("") && !arr[i + 2].Equals("") && !arr[i + 3].Equals("")) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, arr[i + 1] + ";" + arr[i + 2] + ";" + arr[i + 3]); - + int Elevation = Convert.ToInt32(arr[i + 1]); int azimuth = Convert.ToInt32(arr[i + 2]); double cosLen = Math.Cos(Elevation * Math.PI / 180) * (575 / 2); @@ -258,7 +256,7 @@ if (!portSatellite.IsOpen) portSatellite.Open(); if (portSatellite.IsOpen) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "打开串口成功!" + portName); + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "打开卫星状态串口成功!" + portName); } else { @@ -379,7 +377,6 @@ } else if ((sss.Contains("GPGSV") || sss.Contains("BDGSV") || sss.Contains("GBGSV")) && sss.Contains("*")) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "GSV : " + sss); if (sss.Split(',').Length > 8) { if (sss.Contains("GPGSV")) @@ -400,9 +397,7 @@ totalBD = Convert.ToInt32(sss.Split(',')[3]); } } - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "gpList : " + gpList.Count + ",gp共有 :" + +gpMessCount); - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "bdList : " + bdList.Count + ",bd共有 : " + bdMessCount); - + if ((gpList.Count > 0 && gpList.Count == gpMessCount) && (bdList.Count > 0) && bdList.Count == bdMessCount) { if (!drawed) @@ -412,8 +407,7 @@ { lock (obj) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "更新更新更新更新更新画:::: : "); - + panelSite.Refresh(); } diff --git a/RbFreqStandMeasure/tools/DetectionHelper.cs b/RbFreqStandMeasure/tools/DetectionHelper.cs index 6796778..2070bac 100644 --- a/RbFreqStandMeasure/tools/DetectionHelper.cs +++ b/RbFreqStandMeasure/tools/DetectionHelper.cs @@ -84,6 +84,8 @@ if (isUpdates) { isUpdate = true; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度 interval =" + interval + ";detectionItemId="+detectionItemId); + } portStability = port; devIdStability = deviceId; @@ -106,26 +108,30 @@ } private void exeStability1(Object State) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取稳定度1s"); try { lock (obj) { lock(resultStability1) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "isStarted:" + isStarted + ", detectionItemId =" + detectionItemId); - - if (!isStarted) + while (true) { - while (true) - { - if (detectionItemId != -1) + if (detectionItemId != -1) + { + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item==null||(item!=null&&Convert.ToDateTime(item.EndTime) < DateTime.Now)) { + timerStability1.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度1s,devId="+ devIdStability+";detectionItemId="+ detectionItemId); + + return; + } + if (!isStarted) + { isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); - detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); - + detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); @@ -134,83 +140,95 @@ if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - break; } + break; } } string result = ""; - string fre = getFrequencyData(portStability); - if (!fre.Equals("") && resultStability1.Count<101) + string fre = getFrequencyData(portStability,false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,稳定度1s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability1.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "0", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } + if (!fre.Equals("") && resultStability1.Count<101) + { + resultStability1.Add(fre); + if (resultStability1.Count == 101) timerStability1.Dispose(); + if (!isUpdate && count1s < 101) { - resultStability1.Add(fre); - if (resultStability1.Count == 101) timerStability1.Dispose(); - if (!isUpdate && count1s < 101) - { - detectionService.add(devIdStability, fre, "1-1",detectionItemId); - count1s++; - } - } - if (!isUpdate) - { - if (resultStability1.Count == 101) - { - result = FreMath.Stable(resultStability1) + ""; - resultStability1.Clear(); - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "1s稳定度结果:" + result + ", devId =" + devIdStability); - - // 更新检测结果 - detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result, "", "", ""); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detectionId :" + detectionItemId); - - DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); - if (detectionItem != null) - { - //更新稳定度检测状态 - if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) - { - detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); - - } - detectionItem = detectionItemService.searchById(detectionItemId); - //更新整个仪器检测状态 - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); - } - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - } - - } + detectionService.add(devIdStability, fre, "1-1",detectionItemId); + count1s++; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,1s稳定度,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); } - else + } + if (!isUpdate) + { + if (resultStability1.Count == 101) + { + result = FreMath.Stable(resultStability1) + ""; + resultStability1.Clear(); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "1s稳定度测量结果:" + result + ", devId =" + devIdStability + ";detectionItemId=" + detectionItemId); + + // 更新检测结果 + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result, "", "", ""); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detectionId :" + detectionItemId); + + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) + { + //更新稳定度检测状态 + if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) + { + detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + + } + detectionItem = detectionItemService.searchById(detectionItemId); + //更新整个仪器检测状态 + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) + { + deviceService.updateStatus(devIdStability, "3", ""); + } + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + } + + } + } + else + { + if (resultStability1.Count == 101) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度1s"); - if (resultStability1.Count == 101) - { - timerStability1.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度1s得到结果,detectionItemId="+ detectionItemId); - string result1 = FreMath.Stable(resultStability1) + ""; - detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result1, "", "", ""); + timerStability1.Dispose(); - updateView(resultStability1); - stability.label_result.Text = result1; + string result1 = FreMath.Stable(resultStability1) + ""; + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result1, "", "", ""); + + updateView(resultStability1); + stability.label_result.Text = result1; DetailDlg.detailDlg.resultStaStr1 = result1; resultStability1.Clear(); } - } - } + } + } } } catch (Exception ex) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度检测错误:" + ex.Message); - - } } @@ -219,12 +237,20 @@ { lock (obj) { - if (!isStarted) + while (true) { - while (true) + if (detectionItemId != -1) { - if (detectionItemId != -1) + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item == null || (item != null && Convert.ToDateTime(item.EndTime) < DateTime.Now)) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度10s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability10.Dispose(); + return; + } + if (!isStarted) + { isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); @@ -236,15 +262,30 @@ if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - break; + } + break; } } string result = ""; - string fre = getFrequencyData(portStability); + string fre = getFrequencyData(portStability, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,稳定度10s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability10.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "0", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } + if (!fre.Equals("") && resultStability10.Count < 101) { resultStability10.Add(fre); @@ -253,17 +294,18 @@ { detectionService.add(devIdStability, fre, "1-10", detectionItemId); count10s++; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,10s稳定度,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + } - } - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度10s fre=" + fre + ", devId =" + devIdStability); + } + if (!isUpdate) { if (resultStability10.Count == 101) { timerStability10.Dispose(); result = FreMath.Stable(resultStability10) + ""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "10s稳定度检测结果:" + result +", devId =" + devIdStability); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "10s稳定度检测结果:" + result +", devId =" + devIdStability + ";detectionItemId=" + detectionItemId); detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", result, "", ""); @@ -282,7 +324,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); @@ -293,6 +334,8 @@ { if (resultStability10.Count == 101) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度10s得到结果,detectionItemId=" + detectionItemId); + timerStability10.Dispose(); @@ -312,12 +355,20 @@ { lock (obj) { - if (!isStarted) + while (true) { - while (true) + if (detectionItemId != -1) { - if (detectionItemId != -1) + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item == null || (item != null && Convert.ToDateTime(item.EndTime) < DateTime.Now)) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度20s, devId = " + devIdStability + "; detectionItemId = " + detectionItemId); + + timerStability20.Dispose(); + return; + } + if (!isStarted) + { isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); @@ -329,14 +380,28 @@ if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - break; + } + break; } } string result = ""; - string fre = getFrequencyData(portStability); + string fre = getFrequencyData(portStability, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,稳定度20s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability20.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "0", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (!fre.Equals("") && resultStability20.Count < 101) { resultStability20.Add(fre); @@ -344,11 +409,12 @@ { detectionService.add(devIdStability, fre, "1-20", detectionItemId); count20s++; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,20s稳定度,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + } } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度20s fre=" + fre + ", devId =" + devIdStability); - + if (!isUpdate) { if (resultStability20.Count == 101) @@ -356,7 +422,7 @@ timerStability20.Dispose(); result = FreMath.Stable(resultStability20) + ""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "20s稳定度检测结果:" + result + ", devId =" + devIdStability); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "20s稳定度检测结果:" + result + ", devId =" + devIdStability + ";detectionItemId=" + detectionItemId); detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", result, ""); @@ -375,7 +441,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); @@ -389,6 +454,8 @@ { if (resultStability20.Count == 101) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度20s得到结果,detectionItemId=" + detectionItemId); + timerStability20.Dispose(); @@ -414,6 +481,15 @@ { while (true) { + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item == null || (item != null && Convert.ToDateTime(item.EndTime) < DateTime.Now)) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度100s, devId = " + devIdStability + "; detectionItemId = " + detectionItemId); + + timerStability100.Dispose(); + return; + } + if (detectionItemId != -1) { isStarted = true; @@ -427,21 +503,39 @@ if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - break; + } + break; } } string result = ""; - string fre = getFrequencyData(portStability); + string fre = getFrequencyData(portStability, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,稳定度100s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability100.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", "0"); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (!fre.Equals("") && resultStability100.Count < 101) { resultStability100.Add(fre); - if (!isUpdate) detectionService.add(devIdStability, fre, "1-100", detectionItemId); - } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "稳定度100s fre=" + fre + ", devId =" + devIdStability); + if (!isUpdate) + { + detectionService.add(devIdStability, fre, "1-100", detectionItemId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,100s稳定度,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + } + } + if (!isUpdate) { @@ -450,7 +544,7 @@ timerStability100.Dispose(); result = FreMath.Stable(resultStability100) + ""; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "100s稳定度检测结果:" + result + ", devId =" + devIdStability); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "100s稳定度检测结果:" + result + ", devId =" + devIdStability + ";detectionItemId=" + detectionItemId); detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", result); @@ -469,7 +563,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); } @@ -480,6 +573,8 @@ { if (resultStability100.Count == 101) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度100s得到结果,detectionItemId=" + detectionItemId); + timerStability100.Dispose(); string result1 = FreMath.Stable(resultStability100) + ""; @@ -514,57 +609,77 @@ TimeSpan secondSpan = new TimeSpan(Convert.ToDateTime(endTime).Ticks - DateTime.Now.Ticks); delay = (int)secondSpan.TotalMilliseconds - 20*1000; } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "准确度 endtime:"+endTime + "; delay:"+delay); - + timerAccuracy = new System.Threading.Timer(exeAccuracy, null, delay + 200 ,5*60*1000); } private void exeAccuracy(Object State) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "哈哈哈哈,检测准确度了!!!!!!!"+DateTime.Now.ToLongTimeString()); - + { try { lock (obj) { - if (!isStarted) + while (true) { - while (true) + if (detectionItemId != -1) { - if (detectionItemId != -1) + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item == null || (item != null && Convert.ToDateTime(item.EndTime) < DateTime.Now)) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,准确度, devId=" + devIdAccuracy + ";detectionItemId=" + detectionItemId); + + timerAccuracy.Dispose(); + return; + } + if (!isStarted) + { + isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); - if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); - if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); - if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); - if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); - if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); + if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); + if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); if (detectionItem0.Accuracy.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "-1", "", "", "", "", "", "", ""); if (detectionItem0.BootFeature.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "-1", "", "", "", "", "", ""); if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - break; + } + break; } } - if (isUpdate) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测准确度!!!!!!!开始"); string result = ""; double sum = 0.0; List resultList = new List(); for (int i = 0; i < 500; i++) { - string fre = getFrequencyData(portAccuracy); + string fre = getFrequencyData(portAccuracy, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,准确度,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerAccuracy.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (fre.Equals("")) continue; resultList.Add(fre); if (!isUpdate) { detectionService.add(devIdAccuracy, fre, "2", detectionItemId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,准确度, devId=" + devIdAccuracy + ";detectionItemId=" + detectionItemId); + } - if (resultList.Count == 3) + if (resultList.Count == 3) { sum = sum + Convert.ToDouble(fre); break; @@ -584,20 +699,21 @@ } if (!isUpdate) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "准确度检测结果result="+result+",detectionItemId=" + detectionItemId); + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); if (detectionItem != null) { if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdAccuracy, "3", ""); - portAccuracy.Close(); } } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); } else { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新label_result:" + result); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测准确度得到结果,detectionItemId=" + detectionItemId); accuracy.label_result.Text = result; DetailDlg.detailDlg.resultAccStr = result; @@ -638,7 +754,14 @@ lock (obj) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "isStarted:"+ isStarted); + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item == null || (item != null && Convert.ToDateTime(item.EndTime) < DateTime.Now)) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,开机特性, devId=" + devIdAccuracy + ";detectionItemId=" + detectionItemId); + timerBootFeature.Dispose(); + return; + } if (!isStarted) { while (true) @@ -649,11 +772,11 @@ { isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); - if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); - if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); - if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); - if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); - if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); + if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); + if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); if (detectionItem0.Accuracy.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "-1", "", "", "", "", "", "", ""); if (detectionItem0.BootFeature.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "-1", "", "", "", "", "", ""); if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); @@ -664,22 +787,36 @@ } } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测开机特性"); - + string result = ""; double sum = 0.0; int count = 0; for (int i = 0; i < 50; i++) { - string fre = getFrequencyData(portBootFeature); + string fre = getFrequencyData(portBootFeature, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,开机特性,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerBootFeature.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (!fre.Equals("")) { count++; sum = sum + Convert.ToDouble(fre); + if (count == 3) break; } } detectionService.add(devIdBootFeature, sum / 3 + "", "3", detectionItemId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,开机特性, devId=" + devIdAccuracy + ";detectionItemId=" + detectionItemId); + resultBootFeature.Add(sum / 3 + ""); if (resultBootFeature.Count == 8) @@ -693,6 +830,7 @@ if (Convert.ToDouble(fre) < Convert.ToDouble(min) || min.Equals("0.0")) min = fre; } result = (Convert.ToDouble(max) - Convert.ToDouble(min)) + ""; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开机特性检测结果result=" + result + ",detectionItemId=" + detectionItemId); detectionItemService.updateDetecStatus(detectionItemId, "", "", result, "", "", "", "", "", ""); @@ -702,7 +840,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdBootFeature, "3", ""); - portBootFeature.Close(); } } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); @@ -736,26 +873,36 @@ { lock (obj) { - if (!isStarted) + while (true) { - while (true) + if (detectionItemId != -1) { - if (detectionItemId != -1) + DetectionItem item = detectionItemService.getById(detectionItemId); + if (item == null || (item != null && Convert.ToDateTime(item.EndTime) < DateTime.Now)) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,日老化率, devId=" + devIdAccuracy + ";detectionItemId=" + detectionItemId); + + timerAgeRate.Dispose(); + return; + } + if (!isStarted) + { + isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); - if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); - if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); - if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); - if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); - if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); + if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); + if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); if (detectionItem0.Accuracy.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "-1", "", "", "", "", "", "", ""); if (detectionItem0.BootFeature.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "-1", "", "", "", "", "", ""); if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - break; + } + break; } } @@ -766,15 +913,30 @@ int count = 0; for (int i = 0; i < 50; i++) { - string fre = getFrequencyData(portAgeRate); + string fre = getFrequencyData(portAgeRate, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,日老化率,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerAgeRate.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (!fre.Equals("")) { count++; sum = sum + Convert.ToDouble(fre); + if (count == 3) break; } } detectionService.add(devIdAgeRate, sum / 3+"", "4", detectionItemId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,日老化率, devId=" + devIdAccuracy + ";detectionItemId=" + detectionItemId); + resultAgeRate.Add(sum / 3 + ""); if (resultAgeRate.Count == 15) @@ -783,7 +945,7 @@ double r = 0.0; double k = FreMath.DriftRate(resultAgeRate, out r); result = k + "," + r.ToString().Substring(0,5); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "日老化率检测结果:" + result); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "日老化率检测结果result=" + result + ",detectionItemId=" + detectionItemId); detectionItemService.updateDetecStatus(detectionItemId, "", "", "", result, "", "", "", "", ""); @@ -793,7 +955,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdAgeRate, "3", ""); - portAgeRate.Close(); } } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); @@ -808,7 +969,7 @@ // 获取检测数据 - public string getFrequencyData(SerialPort port) + public string getFrequencyData(SerialPort port, bool isTest) { string received = ""; try @@ -818,15 +979,20 @@ if (!isUsing) { isUsing = true; - if (port.IsOpen) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "portname:" + port.PortName); - else LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, port.PortName + " port closed"); + if (!port.IsOpen) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, port.PortName + " closed!!!!!!"); + string name = ConfigHelper.getKeyByValue(port.PortName + " 115200").Replace("channel", "通道"); + MessageBox.Show(name+"的端口异常关闭,该通道上的检测将终止!"); + return "close"; + } if (ConfigHelper.GetAppConfig("deviceType").ToString().Equals("1")) { int count = 0; while (count < 600) { - Thread.Sleep(100); + int readLen = port.BytesToRead; if (readLen > 0) { @@ -855,6 +1021,7 @@ } } count++; + Thread.Sleep(100); } } else @@ -863,7 +1030,7 @@ while (count < 600) { - Thread.Sleep(100); + int readLen = port.BytesToRead; if (readLen > 0) { @@ -889,6 +1056,8 @@ } } count++; + + Thread.Sleep(100); } } @@ -896,7 +1065,14 @@ if (received.Equals("")) { string name = ConfigHelper.getKeyByValue(port.PortName + " 115200").Replace("channel", "通道"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, name + "获取数据失败!" + DateTime.Now.ToLongTimeString()); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, name + "获取数据失败!!!!!!!!!!!!!!" + DateTime.Now.ToLongTimeString()); + if (!isTest) + { + MessageBox.Show("从[" + name + "]获取数据失败,该通道上的检测将终止!"); + return "close"; + } + + return received; } break; } @@ -917,16 +1093,12 @@ } private void updateView(List result) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始更新界面 length:"+ result.Count); - + { isUpdate = false; //new Thread(() => //{ int index = 0; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "DetailDlg.dataGridView.Rows:" + DetailDlg.dataGridView.Rows); - - + foreach (DataGridViewRow row in DetailDlg.dataGridView.Rows) { if (index < result.Count) diff --git a/RbFreqStandMeasure/tools/FreshStatus.cs b/RbFreqStandMeasure/tools/FreshStatus.cs index 517657c..6fba4d9 100644 --- a/RbFreqStandMeasure/tools/FreshStatus.cs +++ b/RbFreqStandMeasure/tools/FreshStatus.cs @@ -156,7 +156,7 @@ if (!portSatellite.IsOpen) portSatellite.Open(); if (portSatellite.IsOpen) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "打开串口成功!" + portName); + LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "打开卫星状态串口成功!" + portName); } else { @@ -189,8 +189,7 @@ totalGP = 0; totalBD = 0; } - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "清空清空清空 : " + dataArray.Length); - int index = -1; + int index = -1; bool drawed = false; bool gga = false; bool rmc = false; @@ -286,8 +285,7 @@ } else if ((sss.Contains("GPGSV") || sss.Contains("BDGSV") || sss.Contains("GBGSV")) && sss.Contains("*")) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "GSV : " + sss); - if (sss.Split(',').Length > 8) + if (sss.Split(',').Length > 8) { if (sss.Contains("GPGSV")) { @@ -307,9 +305,7 @@ totalBD = Convert.ToInt32(sss.Split(',')[3]); } } - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "gpList : " + gpList.Count + ",gp共有 :" + +gpMessCount); - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "bdList : " + bdList.Count+",bd共有 : " + bdMessCount); - + if ((gpList.Count>0 &&gpList.Count == gpMessCount) && (bdList.Count>0) && bdList.Count == bdMessCount) { if (!drawed) @@ -319,8 +315,7 @@ { lock (obj) { - LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "更新更新更新更新更新画:::: : "); - + StatusCtrlForm.statusCtrlForm.Refresh(); }