示例#1
0
        ///// <summary>
        ///// 设置单元格最后两行,在第A库X轴填充值
        ///// </summary>
        ///// <param name="keys"></param>
        //public static void addDataToDataGridViewDataBaseB(ref OilInfoBEntity oilInfoB, ref DataGridView dataGridView, CurveTypeCode typeCode, CurveParmTypeEntity CurveXParmType, CurveParmTypeEntity CurveYParmType)
        //{
        //    if (dataGridView.Rows.Count < 5)
        //        return;

        //    if (typeCode == CurveTypeCode.YIELD || typeCode == CurveTypeCode.DISTILLATE)
        //    {
        //        #region "!RESIDUE"
        //        CurveEntity XCurve = oilInfoB.curves.Where(o => o.propertyX == "ECP" && o.propertyY == CurveXParmType.ItemCode).FirstOrDefault();
        //        CurveEntity YCurve = oilInfoB.curves.Where(o => o.propertyX == "ECP" && o.propertyY == CurveYParmType.ItemCode).FirstOrDefault();

        //        if (XCurve == null || YCurve == null)
        //            return;
        //        if (XCurve.curveDatas.Count <= 0 || YCurve.curveDatas.Count <= 0)
        //            return;

        //        Dictionary<float, List<float>> ECP_X_Y = new Dictionary<float, List<float>>();

        //        for (int index = 0; index < XCurve.curveDatas.Count; index++)
        //        {
        //            float ecp = XCurve.curveDatas[index].xValue;
        //            CurveDataEntity tempCurveData = YCurve.curveDatas.Where(o => o.xValue == ecp).FirstOrDefault();
        //            if (tempCurveData != null)
        //            {
        //                List<float> X_Y = new List<float>();
        //                X_Y.Add(XCurve.curveDatas[index].yValue);
        //                X_Y.Add(tempCurveData.yValue);
        //                ECP_X_Y.Add(ecp, X_Y);
        //            }
        //        }
        //        if (ECP_X_Y.Count <= 0)
        //            return;

        //        foreach (float ECP_Key in ECP_X_Y.Keys)
        //        {
        //            int colIndex = FindItemCodeValueColIndexfromSpecRow(dataGridView, ECP_Key, 2);
        //            if (colIndex != -1)
        //            {
        //                dataGridView.Rows[FrmCurveAGlobal._curveRowXIndex].Cells[colIndex].Value = ECP_X_Y[ECP_Key][0];
        //                dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Value = ECP_X_Y[ECP_Key][1];
        //            }
        //        }
        //        #endregion
        //    }
        //    else if (typeCode == CurveTypeCode.RESIDUE)
        //    {
        //        #region "RESIDUE"
        //        CurveEntity XCurve = oilInfoB.curves.Where(o => o.propertyX == "ECP" && o.propertyY == CurveXParmType.ItemCode).FirstOrDefault();
        //        CurveEntity YCurve = oilInfoB.curves.Where(o => o.propertyX == "WY" && o.propertyY == CurveYParmType.ItemCode).FirstOrDefault();

        //        if (XCurve == null || YCurve == null)
        //            return;
        //        if (XCurve.curveDatas.Count <= 0 || YCurve.curveDatas.Count <= 0)
        //            return;

        //        Dictionary<float, List<float>> ECP_X_Y = new Dictionary<float, List<float>>();

        //        for (int index = 0; index < XCurve.curveDatas.Count; index++)
        //        {
        //            //float ecp = XCurve.curveDatas[index].xValue;
        //            //if (ECP_WYDic.Keys.Contains(ecp))
        //            //{
        //            //    float wy = ECP_WYDic[ecp];
        //            //    CurveDataEntity tempCurveData = YCurve.curveDatas.Where(o => o.xValue == wy).FirstOrDefault();
        //            //    if (tempCurveData != null)
        //            //    {
        //            //        List<float> X_Y = new List<float>();
        //            //        X_Y.Add(XCurve.curveDatas[index].yValue);
        //            //        X_Y.Add(tempCurveData.yValue);
        //            //        ECP_X_Y.Add(ecp, X_Y);
        //            //    }
        //            //}
        //        }
        //        if (ECP_X_Y.Count <= 0)
        //            return;

        //        foreach (float ECP_Key in ECP_X_Y.Keys)
        //        {
        //            int colIndex = FindItemCodeValueColIndexfromSpecRow(dataGridView, ECP_Key, 2);
        //            if (colIndex != -1)
        //            {
        //                dataGridView.Rows[FrmCurveAGlobal._curveRowXIndex].Cells[colIndex].Value = ECP_X_Y[ECP_Key][0];
        //                dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Value = ECP_X_Y[ECP_Key][1];
        //            }
        //        }
        //        #endregion
        //    }
        //}
        #endregion
        /// <summary>
        /// 渣油曲线内插和外延后设置渣油曲线的单元格最后一行的值
        /// </summary>
        /// <param name="dataGridView"></param>
        /// <param name="typeCode"></param>
        /// <param name="CurveXParmType"></param>
        /// <param name="CurveYParmType"></param>
        /// <param name="ECP_WYDataBDic"></param>
        /// <param name="DataBaseBDic"></param>
        public static void addValueToDataGridViewDataBaseBYWhenRESIDUE(ref DataGridView dataGridView, CurveTypeCode typeCode, CurveParmTypeEntity CurveXParmType, CurveParmTypeEntity CurveYParmType, Dictionary <int, float> ECP_WYDataBDic, Dictionary <float, float> DataBaseBDic)
        {
            #region "输入条件判断"
            if (dataGridView.RowCount != 5)
            {
                return;
            }
            if (DataBaseBDic.Count <= 0)
            {
                return;
            }
            if (typeCode != CurveTypeCode.RESIDUE)
            {
                return;
            }

            if (ECP_WYDataBDic == null)
            {
                return;
            }
            if (ECP_WYDataBDic.Count != DataBaseBDic.Count)
            {
                return;
            }
            #endregion

            OilTools          oilTool  = new OilTools();
            OilTableRowEntity tempRowX = OilTableRowBll._OilTableRow.Where(o => o.itemCode == CurveXParmType.ItemCode && o.oilTableTypeID == CurveXParmType.OilTableTypeID).FirstOrDefault();
            OilTableRowEntity tempRowY = OilTableRowBll._OilTableRow.Where(o => o.itemCode == CurveYParmType.ItemCode && o.oilTableTypeID == CurveYParmType.OilTableTypeID).FirstOrDefault();

            dataGridView[FrmCurveAGlobal._dataColStart, FrmCurveAGlobal._curveRowXIndex].Value = dataGridView[FrmCurveAGlobal._dataColStart, 0].Value; //原油性质赋值
            dataGridView[FrmCurveAGlobal._dataColStart, FrmCurveAGlobal._curveRowYIndex].Value = dataGridView[FrmCurveAGlobal._dataColStart, 1].Value; //原油性质赋值

            foreach (int cutPoint in  ECP_WYDataBDic.Keys)
            {
                int colNum = FindItemCodeValueColIndexfromSpecRow(dataGridView, cutPoint, FrmCurveAGlobal._ECPRowIndex);
                if (colNum == -1)
                {
                    continue;
                }
                if (ECP_WYDataBDic[cutPoint].Equals(float.NaN))
                {
                    continue;
                }
                if (DataBaseBDic[ECP_WYDataBDic[cutPoint]].Equals(float.NaN))
                {
                    continue;
                }

                //string strItemCodeValue = oilTool.calDataDecLimit(DataBaseBDic[ECP_WYDataBDic[cutPoint]].ToString(), tempRowY.decNumber,tempRowY.valDigital);
                //dataGridView[colNum, FrmCurveAGlobal._curveRowYIndex].Value = strItemCodeValue;
                dataGridView[colNum, FrmCurveAGlobal._curveRowYIndex].Tag   = DataBaseBDic[ECP_WYDataBDic[cutPoint]].ToString();
                dataGridView[colNum, FrmCurveAGlobal._curveRowYIndex].Value = DataBaseBDic[ECP_WYDataBDic[cutPoint]];
            }
        }
示例#2
0
        /// <summary>
        /// 获取对应类型的字典类型
        /// </summary>
        /// <param name="XItemcode"></param>
        /// <param name="PropertyY"></param>
        /// <param name="oilTableTypeID"></param>
        /// <returns></returns>
        public static Dictionary <ZedGraphOilDataEntity, ZedGraphOilDataEntity> getDictionary(OilInfoEntity oilInfoA, CurveTypeCode typeCode, string XItemCode, string YItemCode, EnumTableType tableType, Color narrowColor, Color wideColor)
        {
            Dictionary <ZedGraphOilDataEntity, ZedGraphOilDataEntity> result = new Dictionary <ZedGraphOilDataEntity, ZedGraphOilDataEntity>();

            if (oilInfoA == null)
            {
                return(result);
            }

            if (typeCode == CurveTypeCode.RESIDUE)
            {
                #region "添加原油性质数据"
                OilDataEntity oilData = oilInfoA.OilDatas.Where(c => c.OilTableTypeID == (int)EnumTableType.Whole &&
                                                                c.OilTableRow.itemCode == YItemCode).FirstOrDefault();

                if (oilData != null && oilData.calData != string.Empty)
                {
                    double D_calDataY = 0;
                    if (double.TryParse(oilData.calData, out D_calDataY))
                    {
                        ZedGraphOilDataEntity key = new ZedGraphOilDataEntity()
                        {
                            ParticipateInCalculation = "true",
                            ColumnIndex   = FrmCurveAGlobal._dataColStart,
                            labData       = "100",
                            calData       = "100",
                            D_CalShowData = 100,
                            D_CalData     = 100
                        };

                        ZedGraphOilDataEntity value = new ZedGraphOilDataEntity()
                        {
                            ParticipateInCalculation = "true",
                            ColumnIndex   = FrmCurveAGlobal._dataColStart,
                            labData       = oilData.calData,
                            calData       = oilData.calData,
                            D_CalShowData = D_calDataY,
                            D_CalData     = D_calDataY
                        };

                        result.Add(key, value);
                    }
                }
                #endregion
            }

            List <OilDataEntity> oilDatasAll = oilInfoA.OilDatas.Where(o => o.OilTableTypeID == (int)tableType && o.calData != string.Empty).ToList();
            if (oilDatasAll.Count <= 0)
            {
                return(result);
            }

            List <OilDataEntity> oilDatas = oilDatasAll.Where(c => c.OilTableRow.itemCode == XItemCode || c.OilTableRow.itemCode == YItemCode).ToList();

            if (oilDatas.Count() <= 0)
            {
                return(result);
            }

            List <OilDataEntity> xList = oilDatas.Where(o => o.OilTableRow.itemCode == XItemCode).ToList(); //x轴的坐标集合
            List <OilDataEntity> yList = oilDatas.Where(o => o.OilTableRow.itemCode == YItemCode).ToList(); //y轴的坐标集合

            if (xList == null || yList == null)
            {
                return(result);
            }

            foreach (var xItem in xList)
            {
                #region "添加数据"
                OilDataEntity yItem = yList.Where(o => o.OilTableCol.colCode == xItem.OilTableCol.colCode).FirstOrDefault();//保证数据对应
                if (yItem == null)
                {
                    continue;
                }

                double d_calDataX = 0, d_calDataY = 0;
                double d_calShowDataX = 0, d_calShowDataY = 0;

                if (double.TryParse(yItem.calShowData, out d_calShowDataY) && double.TryParse(xItem.calShowData, out d_calShowDataX) &&
                    double.TryParse(yItem.calData, out d_calDataY) && double.TryParse(xItem.calData, out d_calDataX))
                {
                    ZedGraphOilDataEntity key = new ZedGraphOilDataEntity()
                    {
                        //ID = xItem.ID,
                        //oilInfoID = xItem.oilInfoID,
                        //oilTableColID = xItem.oilTableColID,
                        //oilTableRowID = xItem.oilTableRowID,
                        ParticipateInCalculation = "true",
                        labData       = xItem.labData,
                        calData       = xItem.calData,
                        D_CalData     = d_calDataX,
                        D_CalShowData = d_calShowDataX,
                        Cell_Color    = tableType == EnumTableType.Narrow ? narrowColor : wideColor
                    };

                    ZedGraphOilDataEntity value = new ZedGraphOilDataEntity()
                    {
                        //ID = yItem.ID,
                        //oilInfoID = yItem.oilInfoID,
                        //oilTableColID = yItem.oilTableColID,
                        //oilTableRowID = yItem.oilTableRowID,
                        ParticipateInCalculation = "true",
                        labData       = yItem.labData,
                        calData       = yItem.calData,
                        D_CalData     = d_calDataY,
                        D_CalShowData = d_calShowDataY,
                        Cell_Color    = tableType == EnumTableType.Narrow ? narrowColor : wideColor
                    };

                    result.Add(key, value);
                }
                #endregion
            }

            return(result);
        }
示例#3
0
        /// <summary>
        /// 从当前的DataGridView中获取数据添加到原油的曲线集合中
        /// </summary>
        /// <param name="oilInfoB">当前原油的曲线集合</param>
        /// <param name="dataGridView">从此表格中获取数据填到原油的曲线数据集合</param>
        /// <param name="typeCode">YIELD收率曲线,DISTILLATE性质曲线,RESIDUE渣油曲线</param>
        /// <param name="CurveXParmType">判断当前原油曲线的X轴参数</param>
        /// <param name="CurveYParmType">判断当前原油曲线的Y轴参数</param>
        public static void getCurrentCurveFromDataGridViewDataBaseB(ref OilInfoBEntity oilInfoB, DataGridView dataGridView, CurveTypeCode typeCode, CurveParmTypeEntity CurveXParmType, CurveParmTypeEntity CurveYParmType)
        {
            if (oilInfoB == null || dataGridView == null || CurveXParmType == null || CurveYParmType == null)
            {
                return;
            }

            if (dataGridView.Rows.Count < 5)
            {
                return;
            }

            if (typeCode == CurveTypeCode.YIELD)
            {
                if (CurveXParmType.ItemCode != PartCurveItemCode.ECP.ToString())//只有X轴为ECP的曲线才保存
                {
                    return;
                }
            }
            else if (typeCode == CurveTypeCode.DISTILLATE)
            {
                if (CurveXParmType.ItemCode != PartCurveItemCode.ECP.ToString())//只有X轴为MCP的曲线才保存
                {
                    return;
                }
            }
            else if (typeCode == CurveTypeCode.RESIDUE)
            {
                if (CurveXParmType.ItemCode != PartCurveItemCode.WY.ToString())
                {
                    return;
                }
            }

            Dictionary <float, float> tempDiC = getDataBaseBfromDataGridView(dataGridView);

            if (tempDiC.Count <= 0)
            {
                return;
            }

            OilTableRowEntity tempRowY = OilTableRowBll._OilTableRow.Where(o => o.itemCode == CurveYParmType.ItemCode).FirstOrDefault();

            #region "曲线的数据点集合赋值"

            List <CurveDataEntity> curveDatas = new List <CurveDataEntity>();
            foreach (float Key in tempDiC.Keys)
            {
                CurveDataEntity curveDataEntity = new CurveDataEntity();
                curveDataEntity.cutPointCP = Key;
                curveDataEntity.xValue     = Key;
                curveDataEntity.yValue     = tempDiC[Key];
                curveDataEntity.XItemCode  = CurveXParmType.ItemCode;
                curveDataEntity.YItemCode  = CurveYParmType.ItemCode;
                curveDatas.Add(curveDataEntity);
            }

            #endregion

            #region "向原油中添加曲线"

            if (curveDatas.Count > 0)
            {
                CurveEntity currentCurve = oilInfoB.curves.Where(o => o.propertyX == CurveXParmType.ItemCode && o.propertyY == CurveYParmType.ItemCode).FirstOrDefault();

                if (currentCurve != null)                 //从内存中找到曲线、删除。
                {
                    oilInfoB.curves.Remove(currentCurve); //此处要考虑从B库取出的数据
                    currentCurve.curveDatas.Clear();
                    currentCurve.curveDatas.AddRange(curveDatas);
                    oilInfoB.curves.Add(currentCurve);
                }
                else
                {
                    //注意此处的曲线没有ID
                    CurveEntity curve = new CurveEntity();
                    curve.curveTypeID = (int)typeCode;
                    curve.oilInfoID   = oilInfoB.ID;
                    curve.propertyX   = CurveXParmType.ItemCode;
                    curve.propertyY   = CurveYParmType.ItemCode;
                    curve.unit        = tempRowY.itemUnit;
                    curve.descript    = tempRowY.itemName;
                    curve.decNumber   = tempRowY.decNumber == null ? tempRowY.valDigital : tempRowY.decNumber.Value;
                    //curve.decNumber = tempRowY.decNumber;
                    curve.curveDatas.AddRange(curveDatas);
                    oilInfoB.curves.Add(curve);
                }
            }
            #endregion
        }
示例#4
0
        /// <summary>
        /// 从应用库中取出曲线
        /// </summary>
        /// <param name="oilInfoBID"></param>
        /// <param name="DataBaseBDIC"></param>
        /// <param name="typeCode"></param>
        /// <param name="CurveXParmType"></param>
        /// <param name="CurveYParmType"></param>
        /// <returns></returns>
        public static CurveEntity getCurrentCurveFromDataBaseB(int oilInfoBID, Dictionary <float, float> DataBaseBDIC, CurveTypeCode typeCode, CurveParmTypeEntity CurveXParmType, CurveParmTypeEntity CurveYParmType)
        {
            if (DataBaseBDIC == null || CurveXParmType == null || CurveYParmType == null)
            {
                return(null);
            }

            if (DataBaseBDIC.Count <= 0)
            {
                return(null);
            }

            if (typeCode == CurveTypeCode.YIELD)
            {
                if (CurveXParmType.ItemCode != PartCurveItemCode.ECP.ToString())//只有X轴为ECP的曲线才保存
                {
                    return(null);
                }
            }
            else if (typeCode == CurveTypeCode.DISTILLATE)
            {
                if (CurveXParmType.ItemCode != PartCurveItemCode.ECP.ToString())//只有X轴为ECP的曲线才保存
                {
                    return(null);
                }
            }
            else if (typeCode == CurveTypeCode.RESIDUE)
            {
                if (CurveXParmType.ItemCode != PartCurveItemCode.WY.ToString())
                {
                    return(null);
                }
            }

            Dictionary <float, float> tempDiC = DataBaseBDIC;

            #region "曲线的数据点集合赋值"

            List <CurveDataEntity> curveDatas = new List <CurveDataEntity>();
            foreach (float Key in tempDiC.Keys)
            {
                CurveDataEntity curveDataEntity = new CurveDataEntity();
                curveDataEntity.cutPointCP = Key;
                curveDataEntity.xValue     = Key;
                curveDataEntity.yValue     = tempDiC[Key];
                curveDataEntity.XItemCode  = CurveXParmType.ItemCode;
                curveDataEntity.YItemCode  = CurveYParmType.ItemCode;
                curveDatas.Add(curveDataEntity);
            }

            #endregion

            #region "向原油中添加曲线"

            if (curveDatas.Count > 0)
            {
                //CurveEntity currentCurve = oilInfoB.curves.Where(o => o.propertyX == CurveXParmType.ItemCode && o.propertyY == CurveYParmType.ItemCode).FirstOrDefault();

                OilTableRowEntity tempRowY = OilTableRowBll._OilTableRow.Where(o => o.itemCode == CurveYParmType.ItemCode).FirstOrDefault();

                //注意此处的曲线没有ID
                CurveEntity curve = new CurveEntity();
                curve.curveTypeID = (int)typeCode;
                curve.oilInfoID   = oilInfoBID;
                curve.propertyX   = CurveXParmType.ItemCode;
                curve.propertyY   = CurveYParmType.ItemCode;
                curve.unit        = tempRowY.itemUnit;
                curve.descript    = tempRowY.itemName;
                curve.decNumber   = tempRowY.decNumber == null ? tempRowY.valDigital : tempRowY.decNumber.Value;
                curve.curveDatas.AddRange(curveDatas);

                return(curve);
            }
            #endregion

            return(null);
        }
示例#5
0
        /// <summary>
        /// 设置非渣油曲线的单元格最后一行的值
        /// </summary>
        /// <param name="dataGridView">需要填充的单元格</param>
        /// <param name="typeCode">曲线的类型</param>
        /// <param name="DataBaseBDic">需要填充的数据</param>
        /// <param name="CurveYParmType">最后一行物性</param>
        public static void addValueToDataGridViewDataBaseBYWhenNORESIDUE(ref DataGridView dataGridView, CurveTypeCode typeCode, Dictionary <float, float> DataBaseBDic, CurveParmTypeEntity CurveYParmType)
        {
            #region "输入条件判断"
            if (dataGridView.RowCount != 5)
            {
                return;
            }
            if (DataBaseBDic.Count <= 0)
            {
                return;
            }
            if (typeCode == CurveTypeCode.RESIDUE)
            {
                return;
            }
            #endregion

            OilTableRowEntity tempRowY = OilTableRowBll._OilTableRow.Where(o => o.itemCode == CurveYParmType.ItemCode && o.oilTableTypeID == CurveYParmType.OilTableTypeID).FirstOrDefault();
            OilTools          oilTool  = new OilTools();

            for (int colIndex = FrmCurveAGlobal._dataColStart; colIndex < dataGridView.ColumnCount; colIndex++)
            {
                object xValue = dataGridView.Rows[FrmCurveAGlobal._curveRowXIndex].Cells[colIndex].Value;//取出第四行的数据

                #region "数据判断"
                if (xValue == null)
                {
                    continue;
                }
                if (xValue.ToString() == "非数字" || xValue.ToString() == "")
                {
                    continue;
                }
                float temp;
                if (!float.TryParse(xValue.ToString(), out temp))
                {
                    continue;
                }
                if (!DataBaseBDic.Keys.Contains(temp))
                {
                    continue;
                }

                float fTempY = DataBaseBDic[temp];
                if (fTempY.Equals(float.NaN))
                {
                    continue;
                }
                #endregion

                object obj = null;
                if (tempRowY.errDownLimit.HasValue && fTempY < tempRowY.errDownLimit ||
                    tempRowY.errUpLimit.HasValue && fTempY > tempRowY.errUpLimit)
                {
                    obj = null;
                }
                else
                {
                    obj = fTempY;
                }
                //if (obj != null)
                //{
                //    if (tempRowY.errUpLimit.HasValue && fTempY > tempRowY.errUpLimit)
                //    {
                //        obj = null;
                //    }
                //    else
                //    {
                //        obj = fTempY;
                //    }
                //}

                //string strTemp = oilTool.calDataDecLimit(fTempY.ToString(), tempRowY.decNumber, tempRowY.valDigital);
                //dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Value = strTemp;
                //dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Tag = fTempY;
                //dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Value = fTempY;

                dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Tag   = obj;
                dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Value = obj;
            }
        }