public void SetData(List <CLDC_DataCore.Model.DnbModel.DnbInfo.MeterBasicInfo> MeterGroup, CLDC_DataCore.Struct.StErrAccord CurItem) { if (Data_View.Columns.Count == 0 || MeterGroup.Count == 0) { return; } int BwRows = CurItem.lstErrPoint.Count; //每个表位包含的检定点数 #region ------初始化或更新数据表单的行 //如果当前数据表单行数小于电能表表位数,则需要重新创建对应数据表单 if (Data_View.Rows.Count != MeterGroup.Count * BwRows) { Data_View.Rows.Clear(); int RowIndex = 0; bool bColor = false; for (int i = 0; i < MeterGroup.Count; i++) { //重构每表位对应的行数 for (int j = 0; j < BwRows; j++) { RowIndex = Data_View.Rows.Add(); if (bColor) { Data_View.Rows[RowIndex].DefaultCellStyle.BackColor = CLDC_DataCore.Const.Variable.Color_Grid_Alter; } else { Data_View.Rows[RowIndex].DefaultCellStyle.BackColor = CLDC_DataCore.Const.Variable.Color_Grid_Normal; } if ((RowIndex) % BwRows == 0)//i * BwRows + j { Data_View[0, RowIndex].Value = MeterGroup[i].ToString(); } Data_View[1, RowIndex].Value = CurItem.lstErrPoint[j].TestPointName; } bColor = !bColor; } } #endregion #region ------填充表单数据------ for (int i = 0; i < MeterGroup.Count; i++) { CLDC_DataCore.Model.DnbModel.DnbInfo.MeterBasicInfo _MeterInfo = MeterGroup[i]; if (!_MeterInfo.YaoJianYn) //如果不检,则置为空 { for (int j = 0; j < BwRows; j++) { DataGridViewRow Row = Data_View.Rows[i * BwRows + j]; for (int k = 2; k < Row.Cells.Count; k++) { Row.Cells[k].Value = string.Empty; } } continue; } string _ItemKey = CurItem.ErrAccordType.ToString(); if (_MeterInfo.MeterErrAccords.ContainsKey(_ItemKey)) //如果数据模型中已经存在该点的数据 { try { for (int j = 0; j < _MeterInfo.MeterErrAccords[_ItemKey].lstTestPoint.Count; j++) { string _subKey = CurItem.lstErrPoint[j].PrjID; if (_MeterInfo.MeterErrAccords[_ItemKey].lstTestPoint.ContainsKey(_subKey)) { DataGridViewRow Row = Data_View.Rows[i * BwRows + j]; //设置检定点颜色 if (_MeterInfo.MeterErrAccords[_ItemKey].lstTestPoint[_subKey].Mea_ItemResult == CLDC_DataCore.Const.Variable.CTG_BuHeGe) //如果不合格修改当前行背景颜色为红色 { Row.DefaultCellStyle.ForeColor = CLDC_DataCore.Const.Variable.Color_Grid_BuHeGe; } else { Row.DefaultCellStyle.ForeColor = Color.Black; } //分解误差 //表位|校验点|误差1|误差2|平均值|化整值|误差1|误差2|平均值|化整值|差值|结论 string[] Arr_Err = _MeterInfo.MeterErrAccords[_ItemKey].lstTestPoint[_subKey].Mea_Wc1.Split('|'); //分解误差 for (int k = 0; k < Arr_Err.Length; k++) { if (k > 4) { break; } Row.Cells[2 + k].Value = Arr_Err[k]; } Arr_Err = _MeterInfo.MeterErrAccords[_ItemKey].lstTestPoint[_subKey].Mea_Wc2.Split('|'); for (int k = 0; k < Arr_Err.Length; k++) { if (k > 4) { break; } Row.Cells[6 + k].Value = Arr_Err[k]; } //差值 Row.Cells[10].Value = _MeterInfo.MeterErrAccords[_ItemKey].lstTestPoint[_subKey].Mea_Wc; //填写当前检定点的结论 Row.Cells[11].Value = _MeterInfo.MeterErrAccords[_ItemKey].lstTestPoint[_subKey].Mea_ItemResult; } } } catch { } } else { for (int j = 0; j < BwRows; j++) { DataGridViewRow Row = Data_View.Rows[i * BwRows + j]; Row.DefaultCellStyle.ForeColor = Color.Black; for (int k = 2; k < Data_View.Columns.Count; k++) { Row.Cells[k].Value = ""; } } } } #endregion }
/// <summary> /// 添加一个需要检定的误差点 /// </summary> /// <param name="WcType">误差类型</param> /// <param name="Time1">时间1</param> /// <param name="Time2">时间2</param> public void Add(CLDC_Comm.Enum.Cus_WcType WcType, string Para1, string Para2, string Para3, string Para4, float time1, float time2) { CLDC_DataCore.Struct.StErrAccord _Point = new CLDC_DataCore.Struct.StErrAccord(); CLDC_DataCore.Struct.StErrAccordbase _PointBase = new StErrAccordbase(); _Point.PrjName = string.Format("{0} {1} {2} {3} {4}", Para1, Para2, Para3, Para4, WcType.ToString()); _Point.lstErrPoint = new List <StErrAccordbase>(); string[] strPara = { Para1, Para2, Para3, Para4 }; //给默认参数 // 功率方向:正向有功 // 元 件:合元 // 谐 波:0不加 // 相 序:0正相续 CLDC_Comm.Enum.Cus_PowerFangXiang _Fx = CLDC_Comm.Enum.Cus_PowerFangXiang.正向有功; CLDC_Comm.Enum.Cus_PowerYuanJian _Yj = CLDC_Comm.Enum.Cus_PowerYuanJian.H; int _XieBo = 0; int _Xx = 0; string strIb = ""; string strGlys = ""; string[] strTmp = new string[2]; for (int i = 0; i < 4; i++) { if (strPara[i].Trim() != "") { strTmp = strPara[i].Split('|'); strIb = strTmp[0]; strGlys = strTmp[1]; _PointBase = new StErrAccordbase(); _PointBase.PrjID = getWcPrjID(WcType, _Fx, _Yj, strGlys, strIb, _XieBo, _Xx); string _GlfxString; switch ((int)_Fx) { case 1: { _GlfxString = "P+"; break; } case 2: { _GlfxString = "P-"; break; } case 3: { _GlfxString = "Q+"; break; } case 4: { _GlfxString = "Q-"; break; } default: { _GlfxString = "P+"; break; } } string strYj = ""; switch (_Yj.ToString().ToUpper()) { case "H": strYj = "合元"; break; case "A": strYj = "A元"; break; case "B": strYj = "B元"; break; case "C": strYj = "C元"; break; default: strYj = "合元"; break; } _PointBase.TestPointName = string.Format("{0} {1} {2} {3}", _GlfxString, strYj, strGlys, strIb); _PointBase.PowerYinSu = strGlys; _PointBase.PowerDianLiu = strIb; _Point.lstErrPoint.Add(_PointBase); } } _Point.ErrAccordType = (int)WcType - 3; _Point.Time1 = time1; _Point.Time2 = time2; _LstErrAccord.Add(_Point); return; }