protected virtual void InitDropDownList() { DestroyDropDownList(); if (string.IsNullOrWhiteSpace(_dropDownTypeCode)) { return; } S_ParmBll paraBll = new S_ParmBll(); List <S_ParmEntity> parms = paraBll.GetParms(_dropDownTypeCode); if (parms == null) { return; } _cellCmb = new ComboBox() { ValueMember = "parmValue", DisplayMember = "parmName", DataSource = parms, DropDownStyle = ComboBoxStyle.DropDownList, Visible = false, }; this.Controls.Add(_cellCmb); _cellCmb.SelectedIndexChanged += DropDownList_SelectedIndexChanged; }
/// <summary> /// 将宽馏分的列数据写入原油 /// </summary> /// <param name="oilA"></param> /// <param name="Data"></param> /// <param name="tableType"></param> private static void WriteToOilA(ref OilInfoEntity oilA, List <WCol> Data, EnumTableType tableType) { try { int colNum = 0; foreach (var col in Data) { #region "获取列ID" colNum++; int oilTableColID = 0; try { oilTableColID = _colCache["Cut" + colNum.ToString(), tableType].ID; } catch { MessageBox.Show("获取不到colID" + colNum.ToString()); } #endregion #region "添加ICP ECP" if (tableType == EnumTableType.Narrow || tableType == EnumTableType.Wide || tableType == EnumTableType.Residue) { if (tableType == EnumTableType.Narrow || tableType == EnumTableType.Wide)//添加icp ecp { #region var oilTableICPRowID = _rowCache["ICP", tableType].ID; OilDataEntity oilDataICP = new OilDataEntity(); oilDataICP.oilInfoID = oilA.ID; oilDataICP.oilTableColID = oilTableColID; oilDataICP.oilTableRowID = oilTableICPRowID; string data = col.ICP == 0 ? "" : col.ICP.ToString(); oilDataICP.labData = data; oilDataICP.calData = data; oilA.OilDatas.Add(oilDataICP); var oilTableECPRowID = _rowCache["ECP", tableType].ID; OilDataEntity oilDataECP = new OilDataEntity(); oilDataECP.oilInfoID = oilA.ID; oilDataECP.oilTableColID = oilTableColID; oilDataECP.oilTableRowID = oilTableECPRowID; data = col.ECP == 0 ? "" : col.ECP.ToString(); oilDataECP.labData = data; oilDataECP.calData = data; oilA.OilDatas.Add(oilDataECP); #endregion } if (tableType == EnumTableType.Residue)//添加icp ecp { #region var ICProw = _rowCache["ICP", tableType]; OilDataEntity oilDataICP = new OilDataEntity(); oilDataICP.oilInfoID = oilA.ID; oilDataICP.oilTableColID = oilTableColID; oilDataICP.oilTableRowID = ICProw.ID; string data = col.ICP.ToString(); oilDataICP.labData = data; oilDataICP.calData = data; oilA.OilDatas.Add(oilDataICP); #endregion } } #endregion #region "添加ICP ECP" if (tableType == EnumTableType.Wide || tableType == EnumTableType.Residue) //如果是“宽馏分”和“渣油” 温度判断是什么油 ,宽 和 渣 才有 WCT { string oilType = GetOilType(col.ICP, col.ECP); //得到wct的种类 S_ParmBll s_ParmBll = new S_ParmBll(); List <S_ParmEntity> wCutTypes; //todo 如果是“渣油”变为rct if (tableType == EnumTableType.Residue) { wCutTypes = s_ParmBll.GetParms("RCT"); } else { wCutTypes = s_ParmBll.GetParms("WCT"); } string WCT = ""; try { WCT = wCutTypes.Where(c => c.parmName == oilType).FirstOrDefault().parmValue; } catch { MessageBox.Show("ICP:" + col.ICP + "ECP:" + col.ECP + "未找到对应原油类型"); } //宽馏分的wct行 var rowWCT = _rowCache["WCT", tableType]; OilDataEntity oilDataWCT = new OilDataEntity(); oilDataWCT.oilInfoID = oilA.ID; oilDataWCT.oilTableColID = oilTableColID; oilDataWCT.oilTableRowID = rowWCT.ID; string data = WCT; if (data.Length > 12) { data = data.Substring(0, 12); } oilDataWCT.labData = data; oilDataWCT.calData = data; oilA.OilDatas.Add(oilDataWCT); } #endregion #region "其他数据赋值" foreach (var item in col.Cells) { OilTableRowEntity rowEntity = null;//根据itemcode得到行id try { if (item.ItemCode == "TYP") { //rowEntity = _rowCache["TYP", EnumTableType.Info]; oilA.type = item.LabData; //更新原油信息 OilBll.saveInfo(oilA); continue; } else { rowEntity = _rowCache[item.ItemCode, tableType]; } if (rowEntity == null) { continue; } } catch { MessageBox.Show("rowEntity获取失败"); } OilDataEntity oilData = new OilDataEntity(); oilData.oilInfoID = oilA.ID; oilData.oilTableColID = oilTableColID; oilData.oilTableRowID = rowEntity.ID; string labData; try { OilTools tools = new OilTools(); if (rowEntity.decNumber != null) { labData = tools.calDataDecLimit(item.LabData, rowEntity.decNumber + 2, rowEntity.valDigital);//输入Execl表的过程中转换数据精度 } else { labData = tools.calDataDecLimit(item.LabData, rowEntity.decNumber, rowEntity.valDigital);//输入Execl表的过程中转换数据精度 } } catch { MessageBox.Show("lab:" + item.LabData); } oilData.labData = item.LabData; oilData.calData = item.LabData; oilA.OilDatas.Add(oilData); } #endregion } } catch (Exception ex) { Log.Error("erro:" + ex); } }