コード例 #1
0
ファイル: PartialFormQuery.cs プロジェクト: Volador17/OilCute
        private void setRemarkDgvRow(Dictionary <string, List <RemarkEntity> > QueryDic, DataGridView dgv)
        {
            #region "添加数据"
            foreach (string key in QueryDic.Keys)//原油的循环判断
            {
                OilInfoEntity tempOil = this._OilAList.Where(o => o.crudeIndex == key).FirstOrDefault();
                if (tempOil == null)//A库不存在
                {
                    continue;
                }

                #region "添加数据"
                foreach (RemarkEntity tempRemark in QueryDic[key])
                {
                    Dictionary <string, string> rowDic = new Dictionary <string, string>();
                    rowDic.Add("ID", tempOil.ID.ToString());
                    rowDic.Add("原油编号", tempOil.crudeIndex);
                    rowDic.Add("原油名称", tempOil.crudeName);
                    rowDic.Add("表名", ((EnumTableType)tempRemark.OilTableTypeID).GetDescription());
                    rowDic.Add("物性", tempRemark.OilTableRow.itemName);
                    rowDic.Add("实测批注", tempRemark.LabRemark);
                    rowDic.Add("校正批注", tempRemark.CalRemark);
                    dgv.Rows.Add(rowDic.Values.ToArray());
                    rowDic.Clear();
                }


                #endregion
            }
            #endregion
        }
コード例 #2
0
 /// <summary>
 /// 初始化表,给表头、行头和单元格赋值
 /// </summary>
 public virtual void InitTable(OilInfoEntity oil, EnumTableType tableType, string dropDownTypeCode = null)
 {
     if (oil == null)
     {
         return;
     }
     _dropDownTypeCode = dropDownTypeCode;
     IsBusy            = true;
     try
     {
         TableType = tableType;
         var tableId = (int)tableType;
         Oil         = oil;
         this._datas = this.Oil.OilDatas.Where(d => d.OilTableTypeID == tableId).ToList();
         var rowCache = new OilTableRowBll();
         var colCache = new OilTableColBll();
         this._rows = rowCache.Where(r => r.oilTableTypeID == tableId).ToList();
         this._cols = colCache.Where(c => c.oilTableTypeID == tableId).ToList();
         OilTableTypeBll tableCache = new OilTableTypeBll();;
         this._tableType = tableCache.FirstOrDefault(t => t.libraryA && t.ID == tableId);
         this._setColHeader();
         this._setRowHeader();
         OnTableLayoutInitialized();
         Application.DoEvents();
         this._setCellValues();
         columnList.FixColumnCount = _cols.Count;
         undoRedoManager.Clear();
         InitDropDownList();
     }
     finally
     {
         IsBusy = false;
     }
 }
コード例 #3
0
ファイル: ExcelToZhenHai.cs プロジェクト: Volador17/OilCute
        /// <summary>
        /// 首先要找到原油信息表,没有原油信息表 则没必要继续下去
        /// </summary>
        /// <param name="oilA"></param>
        /// <param name="ds"></param>
        /// <param name="oilInfoItemCode"></param>
        /// <returns></returns>
        private static OilInfoEntity findOilInfoTalbe(DataSet ds, List <string> oilInfoItemCode)
        {
            OilInfoEntity oilA = new OilInfoEntity();

            #region 找到原油信息表

            string itemCode = string.Empty;

            foreach (DataTable table in ds.Tables)
            {
                int[] firstCode = new int[2] {
                    -1, -1
                };
                for (int r_num = 0; r_num < table.Rows.Count; r_num++)
                {
                    for (int c_num = 0; c_num < table.Columns.Count; c_num++)
                    {
                        string cellContent = table.Rows[r_num][c_num].ToString();
                        cellContent = Units.ToDBC(cellContent);//单元格内容

                        if (!cellContent.Equals("CLA") && oilInfoItemCode.Contains(cellContent))
                        {
                            //原油信息表 第一个代码
                            firstCode[0] = r_num;
                            firstCode[1] = c_num;

                            for (int i = firstCode[0]; i < table.Rows.Count; i++)
                            {
                                itemCode = table.Rows[i][firstCode[1]].ToString().Trim();
                                itemCode = Units.ToDBC(itemCode);
                                string value = table.Rows[i][firstCode[1] + 1].ToString().Trim();
                                value = Units.ToDBC(value);
                                OilBll.oilInfoAddItem(ref oilA, itemCode, value);
                            }
                            oilA.ID = OilBll.saveInfo(oilA);

                            if (oilA.ID == -1)
                            {
                                return(oilA);
                            }
                        }
                        if (firstCode[0] != -1)
                        {
                            break;
                        }
                    }
                    if (firstCode[0] != -1)
                    {
                        break;
                    }
                }
                if (firstCode[0] != -1)
                {
                    break;
                }
            }
            #endregion

            return(oilA);
        }
コード例 #4
0
ファイル: SDGridOilView.cs プロジェクト: Volador17/OilCute
 /// <summary>
 /// 初始化表,给表头、行头和单元格赋值
 /// </summary>
 public void InitTable(OilInfoEntity oil)
 {
     if (oil == null)
     {
         return;
     }
     InitTable(oil, EnumTableType.SimulatedDistillation);
 }
コード例 #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            int num = Convert.ToInt32(txbNum2.Text);
            int rep = Convert.ToInt32(txbRep2.Text);


            this.button2.Text    = "Working";
            this.button2.Enabled = false;
            ThreadStart start2 = () =>
            {
                OilInfoAccess oc  = new OilInfoAccess();
                var           oil = new OilInfoEntity()
                {
                    crudeIndex = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
                    crudeName  = DateTime.Now.ToString("yyyyMMddHHmmssfff")
                };
                oil.ID = oc.Insert(oil);
                for (int i = 0; i < num; i++)
                {
                    var item = new OilDataEntity()
                    {
                        calData       = RIPP.Lib.Security.SecurityTool.MyEncrypt(i.ToString()),
                        labData       = i.ToString(),
                        oilInfoID     = oil.ID,
                        oilTableColID = i,
                        oilTableRowID = i
                    };
                    oil.OilDatas.Add(item);
                }
                OilBll.saveTables(oil);
                this.richTextBox2.AppendText(string.Format("已经插入一条原油数据到数据库 {0}\n", DateTime.Now.ToString()));


                double[] r = new double[rep];
                for (int k = 0; k < rep; k++)
                {
                    DateTime dt  = DateTime.Now;
                    var      ooo = OilBll.GetOilById(oil.ID);
                    foreach (var d in ooo.OilDatas)
                    {
                        var ssss = RIPP.Lib.Security.SecurityTool.MyDecrypt(d.calData);
                    }
                    r[k] = (DateTime.Now - dt).TotalMilliseconds;
                }


                for (int k = 0; k < rep; k++)
                {
                    this.richTextBox2.AppendText(string.Format("读取并解密 {0} 条, 第 {2} 次花费 {1} ms \n", num, r[k], k + 1));
                }
                this.button2.Text    = "Run";
                this.button2.Enabled = true;
                this.richTextBox2.AppendText("\n");
            };

            this.Invoke(start2);
        }
コード例 #6
0
 /// <summary>
 /// 初始化表,给表头、行头和单元格赋值
 /// </summary>
 public void InitTable(OilInfoEntity oil, GridOilViewA gdvWide)
 {
     if (oil == null || gdvWide == null)
     {
         return;
     }
     _gdvWide = gdvWide;
     InitTable(oil, EnumTableType.GCInput, "!Custom");
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: Volador17/OilCute
        private void button2_Click(object sender, EventArgs e)
        {
            int num = Convert.ToInt32(txtNum2.Text);
            int rep = Convert.ToInt32(txtRep2.Text);

            //先搞一条原油数据
            OilInfoAccess oc = new OilInfoAccess();

            this.button2.Text    = "Working";
            this.button2.Enabled = false;
            ThreadStart start2 = () =>
            {
                double[] r = new double[rep];
                for (int k = 0; k < rep; k++)
                {
                    var oil = new OilInfoEntity()
                    {
                        crudeIndex = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
                        crudeName  = DateTime.Now.ToString("yyyyMMddHHmmssfff")
                    };
                    oil.ID = oc.Insert(oil);
                    DateTime dt = DateTime.Now;
                    for (int i = 0; i < num; i++)
                    {
                        var item = new OilDataEntity()
                        {
                            calData       = i.ToString(),
                            labData       = i.ToString(),
                            oilInfoID     = oil.ID,
                            oilTableColID = i,
                            oilTableRowID = i
                        };
                        oil.OilDatas.Add(item);
                    }

                    OilBll.saveTables(oil);
                    r[k] = (DateTime.Now - dt).TotalMilliseconds;
                }

                for (int k = 0; k < rep; k++)
                {
                    this.richTextBox2.AppendText(string.Format("插入 {0} 条, 第 {2} 次花费 {1} ms \n", num, r[k], k + 1));
                }
                this.button2.Text    = "Run";
                this.button2.Enabled = true;
                this.richTextBox2.AppendText("\n");
            };

            this.Invoke(start2);
        }
コード例 #8
0
ファイル: PartialFormQuery.cs プロジェクト: Volador17/OilCute
        /// <summary>
        /// 批注And条件查询
        /// </summary>
        /// <param name="remarkList">一条原油中所有的批注信息</param>
        /// <param name="andSearchList">And查询条件</param>
        /// <param name="queryListResult">查询结果实体集合</param>
        /// <returns></returns>
        private bool getRemarkAndQueryResult(OilInfoEntity oil, EnumTableType tableType, List <OilRangeSearchEntity> andSearchList, List <RemarkEntity> oilAToolQueryList)
        {
            bool BResult = false;
            List <RemarkEntity> remarkList = oil.RemarkList.Where(o => o.OilTableTypeID == (int)tableType && (o.LabRemark != string.Empty || o.CalRemark != string.Empty)).ToList(); //对应表中所有数据

            foreach (OilRangeSearchEntity rangeSearchEntity in andSearchList)                                                                                                        //循环每一个查询条件
            {
                List <RemarkEntity> colDataList = new List <RemarkEntity>();
                string Min      = rangeSearchEntity.downLimit;
                string itemName = rangeSearchEntity.ItemName;

                List <RemarkEntity> itemNameRemarkList = remarkList.Where(o => o.OilTableRow.itemName == itemName).ToList();//对应表中所有数据

                #region "colDataList"
                if (string.IsNullOrWhiteSpace(Min))
                {
                    List <RemarkEntity> result = itemNameRemarkList.Where(o => o.LabRemark.Contains(rangeSearchEntity.RemarkKeyWord) ||
                                                                          o.CalRemark.Contains(rangeSearchEntity.RemarkKeyWord)).ToList();//对应表中所有数据
                    colDataList.AddRange(result);
                }
                else
                {
                    List <RemarkEntity> result = itemNameRemarkList.Where(
                        o => (o.LabRemark.Contains(rangeSearchEntity.RemarkKeyWord) && o.LabRemark.Contains(Min)) ||
                        (o.CalRemark.Contains(rangeSearchEntity.RemarkKeyWord) && o.CalRemark.Contains(Min))).ToList();  //对应表中所有数据

                    colDataList.AddRange(result);
                }

                #endregion

                if (colDataList.Count > 0)//and条件满足一个
                {
                    BResult = true;
                    oilAToolQueryList.AddRange(colDataList);
                }
                else
                {
                    BResult = false;
                    break;
                }
            }

            return(BResult);
        }
コード例 #9
0
ファイル: LibManageBll.cs プロジェクト: Volador17/OilCute
 /// <summary>
 /// 转换为OilInfoEntity
 /// </summary>
 /// <param name="oilInfoEntity">OilInfoEntity实体</param>
 /// <param name="oilInfoOut">oilInfoOut</param>
 public void toOilInfoEntity(ref OilInfoEntity oilInfoEntity, OilInfoOut oilInfoOut)
 {
     oilInfoEntity.crudeName       = oilInfoOut.crudeName;
     oilInfoEntity.englishName     = oilInfoOut.englishName;
     oilInfoEntity.crudeIndex      = oilInfoOut.crudeIndex;
     oilInfoEntity.country         = oilInfoOut.country;
     oilInfoEntity.region          = oilInfoOut.region;
     oilInfoEntity.fieldBlock      = oilInfoOut.fieldBlock;
     oilInfoEntity.sampleDate      = oilInfoOut.sampleDate;
     oilInfoEntity.receiveDate     = oilInfoOut.receiveDate;
     oilInfoEntity.sampleSite      = oilInfoOut.sampleSite;
     oilInfoEntity.assayDate       = oilInfoOut.assayDate;
     oilInfoEntity.updataDate      = oilInfoOut.updataDate;
     oilInfoEntity.sourceRef       = oilInfoOut.sourceRef;
     oilInfoEntity.assayLab        = oilInfoOut.assayLab;
     oilInfoEntity.assayer         = oilInfoOut.assayer;
     oilInfoEntity.assayCustomer   = oilInfoOut.assayCustomer;
     oilInfoEntity.reportIndex     = oilInfoOut.reportIndex;
     oilInfoEntity.summary         = oilInfoOut.summary;
     oilInfoEntity.type            = oilInfoOut.type;
     oilInfoEntity.classification  = oilInfoOut.classification;
     oilInfoEntity.sulfurLevel     = oilInfoOut.sulfurLevel;
     oilInfoEntity.acidLevel       = oilInfoOut.acidLevel;
     oilInfoEntity.corrosionLevel  = oilInfoOut.corrosionLevel;
     oilInfoEntity.processingIndex = oilInfoOut.processingIndex;
     oilInfoEntity.BlendingType    = oilInfoOut.BlendingType;
     oilInfoEntity.NIRSpectrum     = oilInfoOut.NIRSpectrum;
     oilInfoEntity.DataQuality     = oilInfoOut.DataQuality;
     oilInfoEntity.Remark          = oilInfoOut.Remark;
     oilInfoEntity.S_01R           = oilInfoOut.S_01R;
     oilInfoEntity.S_02R           = oilInfoOut.S_02R;
     oilInfoEntity.S_03R           = oilInfoOut.S_03R;
     oilInfoEntity.S_04R           = oilInfoOut.S_04R;
     oilInfoEntity.S_05R           = oilInfoOut.S_05R;
     oilInfoEntity.S_06R           = oilInfoOut.S_06R;
     oilInfoEntity.S_07R           = oilInfoOut.S_07R;
     oilInfoEntity.S_08R           = oilInfoOut.S_08R;
     oilInfoEntity.S_09R           = oilInfoOut.S_09R;
     oilInfoEntity.S_10R           = oilInfoOut.S_10R;
     oilInfoEntity.DataSource      = oilInfoOut.DataSource;
     oilInfoEntity.ICP0            = oilInfoOut.ICP0;
 }
コード例 #10
0
ファイル: LibManageBll.cs プロジェクト: Volador17/OilCute
        /// <summary>
        /// 为OilInfoEntity的原油数据赋值
        /// </summary>
        /// <param name="oilInfoEntity">OilInfoEntity实体</param>
        /// <param name="oilInfoOut">OilInfoOut</param>
        /// <param name="oilTableRows">OilInfoOut的行</param>
        /// <param name="oilTableCols">OilInfoOut的列</param>
        public void toOilDatas(ref OilInfoEntity oilInfoEntity, OilInfoOut oilInfoOut, List <OilTableRowOut> oilTableRows, List <OilTableColOut> oilTableCols)
        {
            OilTableRowBll rowBll = new OilTableRowBll();
            OilTableColBll colBll = new OilTableColBll();

            foreach (OilDataOut oilDataOut in oilInfoOut.oilDatas)  //插入原油数据
            {
                OilDataEntity  oilData        = new OilDataEntity();
                OilTableColOut oilTableColOut = oilTableCols.Where(c => c.ID == oilDataOut.oilTableColID).FirstOrDefault();
                if (oilTableColOut == null)
                {
                    continue;
                }
                string         colCode        = oilTableColOut.colCode;
                OilTableRowOut oilTableRowOut = oilTableRows.Where(c => c.ID == oilDataOut.oilTableRowID).FirstOrDefault();
                if (oilTableRowOut == null)
                {
                    continue;
                }
                string itemCode = oilTableRowOut.itemCode;

                //if (itemCode == "CLA" && oilTableRowOut.oilTableTypeID == 2)
                //    continue;
                //if (itemCode == "A10" && oilTableRowOut.oilTableTypeID == 4)
                //    itemCode = "10A";

                OilTableColEntity col = colBll[colCode, (EnumTableType)oilTableRowOut.oilTableTypeID];
                OilTableRowEntity row = rowBll[itemCode, (EnumTableType)oilTableRowOut.oilTableTypeID];
                if (row != null && col != null)
                {
                    oilData.oilInfoID     = oilInfoEntity.ID;
                    oilData.oilTableColID = col.ID;
                    oilData.oilTableRowID = row.ID;
                    oilData.labData       = oilDataOut.labData;
                    oilData.calData       = oilDataOut.calData;

                    oilInfoEntity.OilDatas.Add(oilData);
                }
            }
        }
コード例 #11
0
ファイル: FrmOpenA.cs プロジェクト: Volador17/OilCute
        /// <summary>
        /// 打开选中的原油A
        /// </summary>
        public override void openOil()
        {
            int oilInfoId = this.gridList.CurrentRow != null?int.Parse(this.gridList.CurrentRow.Cells["ID"].Value.ToString()) : 0;

            OilInfoEntity oil = OilBll.GetOilById(oilInfoId);

            if (oil == null)
            {
                return;
            }
            if (isOilOpening)
            {
                return;
            }

            isOilOpening = true;
            try
            {
                FrmMain frmMain             = this.MdiParent as FrmMain;
                DatabaseA.FrmOilDataA child = (DatabaseA.FrmOilDataA)frmMain.GetChildFrm(oil.crudeIndex + "A");
                if (child == null)
                {
                    DatabaseA.FrmOilDataA form = new DatabaseA.FrmOilDataA(oil);
                    form.MdiParent = frmMain;
                    form.Show();
                    Application.DoEvents();
                }
                else
                {
                    child.Activate();
                }
            }
            finally
            {
                isOilOpening = false;
            }
        }
コード例 #12
0
        /// <summary>
        /// 生成C库
        /// </summary>
        public override void newC()
        {
            string strID      = this.gridList.CurrentRow.Cells["ID"].Value.ToString();
            string crudeIndex = this.gridList.CurrentRow.Cells["原油编号"].Value.ToString();
            int    ID         = 0;

            if (int.TryParse(strID, out ID))
            {
                OilDataSearchAccess        dataSearchAccess = new OilDataSearchAccess();
                List <OilDataSearchEntity> dataList         = dataSearchAccess.Get("oilInfoID =" + ID).ToList();
                if (dataList.Count > 0)
                {
                    DialogResult r = MessageBox.Show("原油" + crudeIndex + "的查询库数据已经存在是否替换?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (r == DialogResult.Yes)
                    {
                        dataSearchAccess.deleteData("Delete from OilDataSearch where oilInfoID =" + ID);

                        OilInfoBEntity oilB = OilBll.GetOilByCrudeIndex(crudeIndex);
                        OilInfoEntity  oilA = OilBll.GetOilById(crudeIndex);
                        if (oilA == null)
                        {
                            OilBll.SaveC(oilB);
                        }
                        else
                        {
                            OilBll.SaveC(oilA, oilB);
                        }
                        MessageBox.Show("原油" + crudeIndex + "生成查询库成功!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        FrmMain frmMain             = this.MdiParent as FrmMain;
                        DatabaseC.FrmOilDataC child = (DatabaseC.FrmOilDataC)frmMain.GetChildFrm(crudeIndex + "C");

                        if (child != null)
                        {
                            MessageBox.Show("原油" + crudeIndex + "的数据窗体需关闭重新打开才有效!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        }
                    }
                }
                else
                {
                    DialogResult r = MessageBox.Show("是否保存数据到快速查询库!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (r == DialogResult.Yes)
                    {
                        dataSearchAccess.deleteData("Delete from OilDataSearch where oilInfoID =" + ID);

                        OilInfoBEntity oilB = OilBll.GetOilByCrudeIndex(crudeIndex);
                        OilInfoEntity  oilA = OilBll.GetOilById(crudeIndex);
                        if (oilA == null)
                        {
                            OilBll.SaveC(oilB);
                        }
                        else
                        {
                            OilBll.SaveC(oilA, oilB);
                        }
                        MessageBox.Show("原油" + crudeIndex + "生成查询库成功!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        FrmMain frmMain             = this.MdiParent as FrmMain;
                        DatabaseC.FrmOilDataC child = (DatabaseC.FrmOilDataC)frmMain.GetChildFrm(crudeIndex + "C");

                        if (child != null)
                        {
                            MessageBox.Show("原油" + crudeIndex + "的数据窗体需关闭重新打开才有效!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("应用库无此条原油!", "警告信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #13
0
 private void dbUpdate(OilInfoEntity item)
 {
     this._access.Update(item, item.ID.ToString());
 }
コード例 #14
0
 private int dbAdd(OilInfoEntity item)
 {
     return(this._access.Insert(item));
 }
コード例 #15
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);
        }
コード例 #16
0
ファイル: ExcelToZhenHai.cs プロジェクト: Volador17/OilCute
        /// <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);
            }
        }
コード例 #17
0
ファイル: ExcelToZhenHai.cs プロジェクト: Volador17/OilCute
        /// <summary>
        /// 导入Excel到库A,并返回原油的oilInfoID
        /// </summary>
        /// <param name="path">excel的路径</param>
        /// <returns></returns>
        public static OilInfoEntity importExcel(string fileName)
        {
            OilInfoEntity oilA = null;

            try
            {
                DataSet ds = ExcelTool.ExcelToDataSet(fileName);

                #region "原油信息表的处理"
                List <string> oilInfoItemCode = OilTableRowBll._OilTableRow.Where(d => d.oilTableTypeID == (int)EnumTableType.Info).Select(d => d.itemCode).Distinct().ToList();
                oilA = findOilInfoTalbe(ds, oilInfoItemCode); //首先要找到原油信息表,没有原油信息表 则没必要继续下去
                if (oilA.ID < 0)
                {
                    return(oilA);
                }
                #endregion

                List <string> allItemCode = OilTableRowBll._OilTableRow.Where(d => new int[] { (int)EnumTableType.Whole, (int)EnumTableType.Light, (int)EnumTableType.Narrow, (int)EnumTableType.Wide, (int)EnumTableType.Residue }.Contains(d.oilTableTypeID)).Select(d => d.itemCode).Distinct().ToList();

                List <WCol> tableColList = new List <WCol>(); //记录所有窄馏分、宽馏分、渣油 数据列集合

                foreach (DataTable table in ds.Tables)        //找到原油信息表后,遍历每个表
                {
                    tableColList.AddRange(getColListFromTable(table, allItemCode));
                }

                #region "对宽馏分数据处理,如果出现ICP,ECP相同的重复列则合并。"
                var items = tableColList.Where(d => d.TableType == EnumTableType.Wide).GroupBy(x => new { x.ICP, x.ECP }).Select(d => new { keys = d.Key, Count = d.Count() });

                foreach (var i in items)
                {
                    if (i.Count > 1)
                    {
                        List <WCol> mergeList = tableColList.Where(d => d.TableType == EnumTableType.Wide && d.ICP == i.keys.ICP && d.ECP == i.keys.ECP).ToList();
                        WCol        newCol    = new WCol();
                        newCol.ECP       = i.keys.ECP;
                        newCol.ICP       = i.keys.ICP;
                        newCol.TableType = EnumTableType.Wide;
                        foreach (var mergeCol in mergeList)
                        {
                            newCol.Cells.AddRange(mergeCol.Cells);
                            tableColList.Remove(mergeCol);
                        }
                        tableColList.Add(newCol);
                    }
                }
                #endregion

                //排序,找出宽馏分的,根据iep排序,渣油也排序
                List <WCol> wideData = tableColList.Where(d => d.TableType == EnumTableType.Wide).OrderBy(d => d.MCP).ToList();
                WriteToOilA(ref oilA, wideData, EnumTableType.Wide);

                wideData = tableColList.Where(d => d.TableType == EnumTableType.Whole).ToList();
                WriteToOilA(ref oilA, wideData, EnumTableType.Whole);

                wideData = tableColList.Where(d => d.TableType == EnumTableType.Narrow).ToList();
                WriteToOilA(ref oilA, wideData, EnumTableType.Narrow);

                wideData = tableColList.Where(d => d.TableType == EnumTableType.Residue).OrderBy(d => d.MCP).ToList();
                WriteToOilA(ref oilA, wideData, EnumTableType.Residue);

                wideData = tableColList.Where(d => d.TableType == EnumTableType.Light).ToList();
                WriteToOilA(ref oilA, wideData, EnumTableType.Light);
            }
            catch (Exception ex)
            {
                Log.Error("数据管理,镇海导入Excel到库原始库:" + ex);
                return(null);
            }

            return(oilA);
        }
コード例 #18
0
ファイル: PartialFormQuery.cs プロジェクト: Volador17/OilCute
        /// <summary>
        /// 查找批注数据
        /// </summary>
        /// <param name="rangeSearchEntityList"></param>
        /// <param name="showQueryEntityList"></param>
        /// <returns></returns>
        private Dictionary <string, List <RemarkEntity> > GetRemarkQueryResult(List <OilRangeSearchEntity> rangeSearchEntityList)
        {
            Dictionary <string, List <RemarkEntity> > resultDIC = new Dictionary <string, List <RemarkEntity> >();//存放查找结果(满足条件的原油编号)

            if (rangeSearchEntityList.Count == 0 || rangeSearchEntityList == null)
            {
                return(resultDIC);
            }

            var crudeIndexEnumable = from oilInfo in this._OilAList
                                     select oilInfo.crudeIndex;

            List <string> crudeIndexList = crudeIndexEnumable.ToList(); //获取A库中的所有原油编号

            foreach (string crudeIndex in crudeIndexList)               //循环每一条原油(Or条件处理完后剩下的满足条件的原油)
            {
                List <RemarkEntity> tempList = new List <RemarkEntity> ();
                resultDIC.Add(crudeIndex, tempList);
            }

            #region "进行数据查找"
            List <OilRangeSearchEntity> searchAndList = new List <OilRangeSearchEntity>(); //范围查找用(And条件)
            List <OilRangeSearchEntity> searchOrList  = new List <OilRangeSearchEntity>(); //范围查找用(Or条件)

            #region "或查找"
            int OrCount = 0;//存放Or组合的个数
            foreach (OilRangeSearchEntity currentOilRangeSearchEntity in rangeSearchEntityList)
            {
                if (currentOilRangeSearchEntity.IsAnd && currentOilRangeSearchEntity.RightParenthesis.Trim() == "")//如果该条件是And,添加到searchAnd中去
                {
                    searchAndList.Add(currentOilRangeSearchEntity);
                    continue;
                }
                else if (!currentOilRangeSearchEntity.IsAnd && currentOilRangeSearchEntity.RightParenthesis.Trim() != ")")//如果该条件是Or,但不是最后一个Or,则添加到searchOr中去,暂时不进行计算
                {
                    searchOrList.Add(currentOilRangeSearchEntity);
                    continue;
                }
                else if (currentOilRangeSearchEntity.RightParenthesis.Trim() == ")")//如果该条件是Or,且是括号中的最后一个Or,则添加到searchOr中去,并进行或的计算
                {
                    #region "Or的计算"
                    searchOrList.Add(currentOilRangeSearchEntity);

                    List <OilRangeSearchEntity> narrowSearchOrList  = searchOrList.Where(o => o.TableTypeID == (int)EnumTableType.Narrow).ToList();  //窄馏分表
                    List <OilRangeSearchEntity> wideSearchOrList    = searchOrList.Where(o => o.TableTypeID == (int)EnumTableType.Wide).ToList();    //宽馏分表
                    List <OilRangeSearchEntity> residueSearchOrList = searchOrList.Where(o => o.TableTypeID == (int)EnumTableType.Residue).ToList(); //渣油表

                    List <OilRangeSearchEntity> wholeSearchOrList   = searchOrList.Where(o => o.TableTypeID == (int)EnumTableType.Whole).ToList();   //原油性质表
                    List <OilRangeSearchEntity> lightSearchOrList   = searchOrList.Where(o => o.TableTypeID == (int)EnumTableType.Light).ToList();   //轻端表
                    List <OilRangeSearchEntity> gcInputSearchOrList = searchOrList.Where(o => o.TableTypeID == (int)EnumTableType.GCInput).ToList(); //GC输入表

                    foreach (string crudeIndex in crudeIndexList)                                                                                    //循环每一条原油
                    {
                        if (OrCount != 0 && resultDIC[crudeIndex] == null)                                                                           //不是第一个Or集合,且结果为null,说明前面已经有Or条件不满足
                        {
                            continue;
                        }
                        if (resultDIC[crudeIndex] == null)//不是第一个Or集合,且结果为null,说明前面已经有Or条件不满足
                        {
                            continue;
                        }

                        OilInfoEntity oil = this._OilAList.Where(o => o.crudeIndex == crudeIndex).FirstOrDefault(); //原油所有数据(除原油信息)

                        if (narrowSearchOrList.Count != 0)                                                          //窄馏分表的查询
                        {
                            bool temp = getRemarkOrQueryResult(oil, EnumTableType.Narrow, narrowSearchOrList, resultDIC[crudeIndex]);
                            if (!temp)//计算结果未变,说明条件不满足
                            {
                                resultDIC[crudeIndex] = null;
                                continue;
                            }
                        }
                        if (wideSearchOrList.Count != 0)//宽馏分表的查询
                        {
                            bool temp = getRemarkOrQueryResult(oil, EnumTableType.Wide, wideSearchOrList, resultDIC[crudeIndex]);
                            if (!temp)//计算结果未变,说明条件不满足
                            {
                                resultDIC[crudeIndex] = null;
                                continue;
                            }
                        }
                        if (residueSearchOrList.Count != 0)//渣油表的查询
                        {
                            bool temp = getRemarkOrQueryResult(oil, EnumTableType.Residue, residueSearchOrList, resultDIC[crudeIndex]);
                            if (!temp)//计算结果未变,说明条件不满足
                            {
                                resultDIC[crudeIndex] = null;
                                continue;
                            }
                        }

                        if (wholeSearchOrList.Count != 0)//原油性质表的查询
                        {
                            bool temp = getRemarkOrQueryResult(oil, EnumTableType.Whole, wholeSearchOrList, resultDIC[crudeIndex]);
                            if (!temp)//计算结果未变,说明条件不满足
                            {
                                resultDIC[crudeIndex] = null;
                                continue;
                            }
                        }
                        if (lightSearchOrList.Count != 0)//轻端表的查询
                        {
                            bool temp = getRemarkOrQueryResult(oil, EnumTableType.Light, lightSearchOrList, resultDIC[crudeIndex]);
                            if (!temp)//计算结果未变,说明条件不满足
                            {
                                resultDIC[crudeIndex] = null;
                                continue;
                            }
                        }
                        if (gcInputSearchOrList.Count > 0)//GC表的查询
                        {
                            //bool temp = getGCInputOrQueryResult(oil, gcInputSearchOrList, resultDIC[crudeIndex]);
                            //if (!temp)//计算结果未变,说明条件不满足
                            //{
                            //    resultDIC[crudeIndex] = null;
                            //    continue;
                            //}
                        }
                    }
                    OrCount++;
                    searchOrList.Clear();//该Or括号计算完后,情况OrList,用于后面的Or括号计算
                    continue;
                    #endregion
                }
            }
            #endregion

            #region And条件按照表类型分类处理

            List <OilRangeSearchEntity> narrowSearchAndList  = searchAndList.Where(o => o.TableTypeID == (int)EnumTableType.Narrow).ToList();  //窄馏分表
            List <OilRangeSearchEntity> wideSearchAndList    = searchAndList.Where(o => o.TableTypeID == (int)EnumTableType.Wide).ToList();    //宽馏分表
            List <OilRangeSearchEntity> residueSearchAndList = searchAndList.Where(o => o.TableTypeID == (int)EnumTableType.Residue).ToList(); //渣油表
            List <OilRangeSearchEntity> wholeSearchAndList   = searchAndList.Where(o => o.TableTypeID == (int)EnumTableType.Whole).ToList();   //原油性质表
            List <OilRangeSearchEntity> lightSearchAndList   = searchAndList.Where(o => o.TableTypeID == (int)EnumTableType.Light).ToList();   //轻端表
            List <OilRangeSearchEntity> gcInputSearchAndList = searchAndList.Where(o => o.TableTypeID == (int)EnumTableType.GCInput).ToList(); //GC输入表

            if (searchAndList.Count > 0)
            {
                List <string> keyList = crudeIndexEnumable.ToList();                                            //获取A库中的所有原油编号
                foreach (string crudeIndex in keyList)                                                          //循环每一条原油(Or条件处理完后剩下的满足条件的原油)
                {
                    OilInfoEntity oil = this._OilAList.Where(o => o.crudeIndex == crudeIndex).FirstOrDefault(); //原油所有数据(除原油信息)

                    if (resultDIC[crudeIndex] == null)
                    {
                        continue;
                    }

                    #region "窄馏分表的查询"
                    if (narrowSearchAndList.Count != 0)//窄馏分表的查询
                    {
                        bool temp = getRemarkAndQueryResult(oil, EnumTableType.Narrow, narrowSearchAndList, resultDIC[crudeIndex]);

                        if (!temp)//计算结果未变,说明条件不满足
                        {
                            resultDIC[crudeIndex] = null;
                            continue;
                        }
                    }
                    #endregion

                    #region "宽馏分表的查询"
                    if (wideSearchAndList.Count != 0)//宽馏分表的查询
                    {
                        bool temp = getRemarkAndQueryResult(oil, EnumTableType.Wide, wideSearchAndList, resultDIC[crudeIndex]);
                        if (!temp)//计算结果未变,说明条件不满足
                        {
                            resultDIC[crudeIndex] = null;
                            continue;
                        }
                    }
                    #endregion

                    #region "渣油表的查询"
                    if (residueSearchAndList.Count != 0)//渣油表的查询
                    {
                        bool temp = getRemarkAndQueryResult(oil, EnumTableType.Residue, residueSearchAndList, resultDIC[crudeIndex]);
                        if (!temp)//计算结果未变,说明条件不满足
                        {
                            resultDIC[crudeIndex] = null;
                            continue;
                        }
                    }
                    #endregion

                    #region "原油性质"
                    if (wholeSearchAndList.Count != 0)//原油性质表的查询
                    {
                        bool temp = getRemarkAndQueryResult(oil, EnumTableType.Whole, wholeSearchAndList, resultDIC[crudeIndex]);
                        if (!temp)//计算结果未变,说明条件不满足
                        {
                            resultDIC[crudeIndex] = null;
                            continue;
                        }
                    }

                    #endregion

                    #region "轻端表的查询"

                    if (lightSearchAndList.Count != 0)//轻端表的查询
                    {
                        bool temp = getRemarkAndQueryResult(oil, EnumTableType.Light, lightSearchAndList, resultDIC[crudeIndex]);
                        if (!temp)//计算结果未变,说明条件不满足
                        {
                            resultDIC[crudeIndex] = null;
                            continue;
                        }
                    }
                    #endregion

                    #region "GC输入表的查询"

                    if (gcInputSearchAndList.Count != 0)//轻端表的查询
                    {
                        //bool temp = getGCInputAndQueryResult(oil, gcInputSearchAndList, resultDIC[crudeIndex]);
                        //if (!temp)//计算结果未变,说明条件不满足
                        //{
                        //    resultDIC[crudeIndex] = null;
                        //    continue;
                        //}
                    }
                    #endregion
                }
            }

            #endregion
            #endregion

            List <string> tempKeyList = resultDIC.Keys.ToList();
            foreach (string crudeIndex in tempKeyList)//把不满足条件的原油从结果中去掉
            {
                if (resultDIC[crudeIndex] == null)
                {
                    resultDIC.Remove(crudeIndex);
                }
            }

            return(resultDIC);
        }
コード例 #19
0
ファイル: FrmSummary.cs プロジェクト: Volador17/OilCute
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="frmOilDataA"></param>
 public FrmSummary(DatabaseA.FrmOilDataA frmOilDataA)
 {
     InitializeComponent();
     this._OilA = frmOilDataA.getData();
     this.Text  = "原油" + this._OilA.crudeName + "评论";
 }
コード例 #20
0
ファイル: Test.cs プロジェクト: Volador17/OilCute
 void Test_Load(object sender, EventArgs e)
 {
     OilInfoEntity oil = OilBll.GetOilById("test原油1");
     var           dd  = oil.OilDatas;
 }
コード例 #21
0
ファイル: OilCApplyBll.cs プロジェクト: Volador17/OilCute
 /// <summary>
 /// 构造函数
 /// </summary>
 public OilCApplyBll(OilInfoEntity oilA, OilInfoBEntity oilB)
 {
     this._oilA = oilA;
     this._oilB = oilB;
     this._cutMothedEntityList = OilSearchCutMothed();//切割方案
 }
コード例 #22
0
ファイル: OilCApplyBll.cs プロジェクト: Volador17/OilCute
        /// <summary>
        /// 找出A库中已经存在的值不用计算
        /// </summary>
        /// <param name="cutDataList"></param>
        /// <returns></returns>
        private List <OilDataSearchEntity> findOilDataSearch(OilInfoEntity oilA, OilInfoBEntity oilB)
        {
            List <OilDataSearchEntity> dataSearchList = new List <OilDataSearchEntity>();//需要返回的查找数据

            OilDataSearchRowAccess        dataSearchRowAccess = new OilDataSearchRowAccess();
            List <OilDataSearchRowEntity> dataSearchRows      = dataSearchRowAccess.Get("1=1").ToList();
            OilDataSearchColAccess        dataSearchColAccess = new OilDataSearchColAccess();
            List <OilDataSearchColEntity> dataSearchCols      = dataSearchColAccess.Get("1=1").ToList();

            #region "A库中查找"
            #region "原油信息表的查找数据"
            List <OilDataSearchColEntity> infoDataSearchCols = dataSearchCols.Where(o => o.OilTableName == "原油信息").ToList();
            int infoOilTalbeColID = infoDataSearchCols[0].OilTableColID;
            List <OilDataSearchRowEntity> oilDataRowEntityList = dataSearchRows.Where(o => o.OilTableRow.oilTableTypeID == (int)EnumTableType.Info).ToList();

            foreach (OilDataSearchRowEntity e in oilDataRowEntityList)
            {
                OilDataSearchEntity infoDataSearch = new OilDataSearchEntity();
                dataSearchList.Add(infoDataSearch);
                infoDataSearch.oilInfoID     = this._oilB.ID;
                infoDataSearch.oilTableColID = infoOilTalbeColID;
                infoDataSearch.oilTableRowID = e.OilTableRowID;
                #region
                if (e.OilTableRow.itemCode == "CNA")
                {
                    infoDataSearch.calData = oilA.crudeName;
                }
                else if (e.OilTableRow.itemCode == "ENA")
                {
                    infoDataSearch.calData = oilA.englishName;
                }
                else if (e.OilTableRow.itemCode == "IDC")
                {
                    infoDataSearch.calData = oilA.crudeIndex;
                }
                else if (e.OilTableRow.itemCode == "COU")
                {
                    infoDataSearch.calData = oilA.country;
                }
                else if (e.OilTableRow.itemCode == "GRC")
                {
                    infoDataSearch.calData = oilA.region;
                }
                else if (e.OilTableRow.itemCode == "ADA")
                {
                    infoDataSearch.calData = oilA.receiveDate != null?oilA.assayDate.ToString() : string.Empty;
                }
                else if (e.OilTableRow.itemCode == "ALA")
                {
                    infoDataSearch.calData = oilA.assayLab;
                }
                #endregion

                #region
                else if (e.OilTableRow.itemCode == "AER")
                {
                    infoDataSearch.calData = oilA.assayer;
                }
                else if (e.OilTableRow.itemCode == "SR")
                {
                    infoDataSearch.calData = oilA.sourceRef;
                }
                else if (e.OilTableRow.itemCode == "ASC")
                {
                    infoDataSearch.calData = oilA.assayCustomer;
                }
                else if (e.OilTableRow.itemCode == "RIN")
                {
                    infoDataSearch.calData = oilA.reportIndex;
                }
                else if (e.OilTableRow.itemCode == "CLA")
                {
                    infoDataSearch.calData = oilA.type;
                }
                else if (e.OilTableRow.itemCode == "TYP")
                {
                    infoDataSearch.calData = oilA.classification;
                }
                else if (e.OilTableRow.itemCode == "SCL")
                {
                    infoDataSearch.calData = oilA.sulfurLevel;
                }
                #endregion
            }
            #endregion

            #region "原油性质表的查找数据"
            OilDataSearchColEntity        wholeSearchCol = dataSearchCols.Where(o => o.OilTableName == "原油性质").FirstOrDefault();
            List <OilDataSearchRowEntity> wholeRowList   = wholeSearchCol.OilDataRowList;
            foreach (OilDataSearchRowEntity wholeRow in wholeRowList)
            {
                OilDataEntity wholeData = oilA.OilDatas.Where(o => o.oilTableRowID == wholeRow.OilTableRowID).FirstOrDefault();
                float         temp      = 0;
                if (wholeData != null && !string.IsNullOrWhiteSpace(wholeData.calData) && float.TryParse(wholeData.calData, out temp))
                {
                    OilDataSearchEntity DataSearch = new OilDataSearchEntity();
                    dataSearchList.Add(DataSearch);
                    DataSearch.oilInfoID     = this._oilB.ID;
                    DataSearch.oilTableColID = wholeSearchCol.OilTableColID;
                    DataSearch.oilTableRowID = wholeRow.OilTableRowID;
                    DataSearch.calData       = wholeData.calData;
                }
            }
            #endregion

            #region "宽馏分表和渣油表"
            foreach (CutMothedEntity cutMothed in this._cutMothedEntityList)
            {
                int oilTableColID = 0;
                #region "取出列代码"
                if (cutMothed.ECP <= 1500)
                {
                    List <OilDataEntity> ICPList = oilA.OilDatas.Where(o => o.OilTableRow.itemCode == "ICP" && o.calShowData.ToString() == cutMothed.ICP.ToString() && o.OilTableTypeID == (int)EnumTableType.Wide).ToList();
                    List <OilDataEntity> ECPList = oilA.OilDatas.Where(o => o.OilTableRow.itemCode == "ECP" && o.calShowData.ToString() == cutMothed.ECP.ToString() && o.OilTableTypeID == (int)EnumTableType.Wide).ToList();

                    foreach (OilDataEntity ICP in ICPList)
                    {
                        foreach (OilDataEntity ECP in ECPList)
                        {
                            if (ICP.OilTableCol.colCode == ECP.OilTableCol.colCode)
                            {
                                oilTableColID = ECP.oilTableColID;
                                break;
                            }
                        }
                    }
                }
                else if (cutMothed.ECP > 1500)
                {
                    OilDataEntity ICP = oilA.OilDatas.Where(o => o.OilTableRow.itemCode == "ICP" && o.calShowData == cutMothed.ICP.ToString() && o.OilTableTypeID == (int)EnumTableType.Residue).FirstOrDefault();
                    if (ICP != null)
                    {
                        oilTableColID = ICP.oilTableColID;
                    }
                }
                #endregion

                OilDataSearchColEntity        dataSearchCol      = dataSearchCols.Where(o => o.OilTableName == cutMothed.Name).FirstOrDefault();
                List <OilDataSearchRowEntity> wideDataSearchRows = dataSearchCol.OilDataRowList;
                if (oilTableColID > 0)
                {
                    foreach (OilDataSearchRowEntity dataSearchRow in wideDataSearchRows)
                    {
                        OilDataEntity data = oilA.OilDatas.Where(o => o.oilTableRowID == dataSearchRow.OilTableRowID && o.oilTableColID == oilTableColID).FirstOrDefault();
                        float         temp = 0;
                        if (data != null && !string.IsNullOrWhiteSpace(data.calData) && float.TryParse(data.calData, out temp))
                        {
                            OilDataSearchEntity DataSearch = new OilDataSearchEntity();
                            dataSearchList.Add(DataSearch);
                            DataSearch.oilInfoID     = this._oilB.ID;
                            DataSearch.oilTableColID = dataSearchCol.OilTableColID;
                            DataSearch.oilTableRowID = dataSearchRow.OilTableRowID;
                            DataSearch.calData       = data.calData;
                        }
                    }
                }
            }
            #endregion
            #endregion

            #region "B库中查找"
            #region "原油信息表的查找数据"

            foreach (OilDataSearchRowEntity e in oilDataRowEntityList)
            {
                OilDataSearchEntity dataSearchEntity = dataSearchList.Where(o => o.oilTableColID == infoOilTalbeColID && o.oilTableRowID == e.OilTableRowID).FirstOrDefault();

                if (dataSearchEntity == null)
                {
                    OilDataSearchEntity wholeDataSearch = new OilDataSearchEntity();
                    dataSearchList.Add(wholeDataSearch);
                    wholeDataSearch.oilInfoID     = this._oilB.ID;
                    wholeDataSearch.oilTableColID = infoOilTalbeColID;
                    wholeDataSearch.oilTableRowID = e.OilTableRowID;


                    #region
                    if (e.OilTableRow.itemCode == "CNA")
                    {
                        wholeDataSearch.calData = oilB.crudeName;
                    }
                    else if (e.OilTableRow.itemCode == "ENA")
                    {
                        wholeDataSearch.calData = oilB.englishName;
                    }
                    else if (e.OilTableRow.itemCode == "IDC")
                    {
                        wholeDataSearch.calData = oilB.crudeIndex;
                    }
                    else if (e.OilTableRow.itemCode == "COU")
                    {
                        wholeDataSearch.calData = oilB.country;
                    }
                    else if (e.OilTableRow.itemCode == "GRC")
                    {
                        wholeDataSearch.calData = oilB.region;
                    }
                    else if (e.OilTableRow.itemCode == "ADA")
                    {
                        wholeDataSearch.calData = oilB.receiveDate != null?oilB.receiveDate.ToString() : string.Empty;
                    }
                    else if (e.OilTableRow.itemCode == "ALA")
                    {
                        wholeDataSearch.calData = oilB.assayLab;
                    }
                    #endregion

                    #region
                    if (e.OilTableRow.itemCode == "AER")
                    {
                        wholeDataSearch.calData = oilB.assayer;
                    }
                    else if (e.OilTableRow.itemCode == "SR")
                    {
                        wholeDataSearch.calData = oilB.sourceRef;
                    }
                    else if (e.OilTableRow.itemCode == "ASC")
                    {
                        wholeDataSearch.calData = oilB.assayCustomer;
                    }
                    else if (e.OilTableRow.itemCode == "RIN")
                    {
                        wholeDataSearch.calData = oilB.reportIndex;
                    }
                    else if (e.OilTableRow.itemCode == "CLA")
                    {
                        wholeDataSearch.calData = oilB.type;
                    }
                    else if (e.OilTableRow.itemCode == "TYP")
                    {
                        wholeDataSearch.calData = oilB.classification;
                    }
                    else if (e.OilTableRow.itemCode == "SCL")
                    {
                        wholeDataSearch.calData = oilB.sulfurLevel;
                    }
                    #endregion
                }
                else if (dataSearchEntity != null && string.IsNullOrWhiteSpace(dataSearchEntity.calData))
                {
                    OilDataSearchEntity wholeDataSearch = new OilDataSearchEntity();
                    dataSearchList.Add(wholeDataSearch);
                    wholeDataSearch.oilInfoID     = this._oilB.ID;
                    wholeDataSearch.oilTableColID = infoOilTalbeColID;
                    wholeDataSearch.oilTableRowID = e.OilTableRowID;


                    #region
                    if (e.OilTableRow.itemCode == "CNA")
                    {
                        wholeDataSearch.calData = oilB.crudeName;
                    }
                    else if (e.OilTableRow.itemCode == "ENA")
                    {
                        wholeDataSearch.calData = oilB.englishName;
                    }
                    else if (e.OilTableRow.itemCode == "IDC")
                    {
                        wholeDataSearch.calData = oilB.crudeIndex;
                    }
                    else if (e.OilTableRow.itemCode == "COU")
                    {
                        wholeDataSearch.calData = oilB.country;
                    }
                    else if (e.OilTableRow.itemCode == "GRC")
                    {
                        wholeDataSearch.calData = oilB.region;
                    }
                    else if (e.OilTableRow.itemCode == "ADA")
                    {
                        wholeDataSearch.calData = oilB.receiveDate != null?oilB.receiveDate.ToString() : string.Empty;
                    }
                    else if (e.OilTableRow.itemCode == "ALA")
                    {
                        wholeDataSearch.calData = oilB.assayLab;
                    }
                    #endregion

                    #region
                    if (e.OilTableRow.itemCode == "AER")
                    {
                        wholeDataSearch.calData = oilB.assayer;
                    }
                    else if (e.OilTableRow.itemCode == "SR")
                    {
                        wholeDataSearch.calData = oilB.sourceRef;
                    }
                    else if (e.OilTableRow.itemCode == "ASC")
                    {
                        wholeDataSearch.calData = oilB.assayCustomer;
                    }
                    else if (e.OilTableRow.itemCode == "RIN")
                    {
                        wholeDataSearch.calData = oilB.reportIndex;
                    }
                    else if (e.OilTableRow.itemCode == "CLA")
                    {
                        wholeDataSearch.calData = oilB.type;
                    }
                    else if (e.OilTableRow.itemCode == "TYP")
                    {
                        wholeDataSearch.calData = oilB.classification;
                    }
                    else if (e.OilTableRow.itemCode == "SCL")
                    {
                        wholeDataSearch.calData = oilB.sulfurLevel;
                    }
                    #endregion
                }
            }
            #endregion

            #region "原油性质表的查找数据"
            for (int wholeIndex = 0; wholeIndex < wholeRowList.Count; wholeIndex++)
            {
                OilDataSearchEntity dataSearchEntity = dataSearchList.Where(o => o.oilTableColID == wholeSearchCol.OilTableColID && o.oilTableRowID == wholeRowList[wholeIndex].OilTableRowID).FirstOrDefault();

                OilDataBEntity wholeData = oilB.OilDatas.Where(o => o.oilTableRowID == wholeRowList[wholeIndex].OilTableRowID).FirstOrDefault();
                if (dataSearchEntity == null)
                {
                    if (wholeData != null && !string.IsNullOrWhiteSpace(wholeData.calData))
                    {
                        OilDataSearchEntity wholeDataSearch = new OilDataSearchEntity();
                        dataSearchList.Add(wholeDataSearch);
                        wholeDataSearch.oilInfoID     = this._oilB.ID;
                        wholeDataSearch.oilTableColID = wholeSearchCol.OilTableColID;
                        wholeDataSearch.oilTableRowID = wholeRowList[wholeIndex].OilTableRowID;
                        wholeDataSearch.calData       = wholeData.calData;
                    }
                }
                else if (dataSearchEntity != null && string.IsNullOrWhiteSpace(dataSearchEntity.calData))
                {
                    if (wholeData != null && !string.IsNullOrWhiteSpace(wholeData.calData))
                    {
                        dataSearchEntity.oilInfoID     = this._oilB.ID;
                        dataSearchEntity.oilTableColID = wholeSearchCol.OilTableColID;
                        dataSearchEntity.oilTableRowID = wholeRowList[wholeIndex].OilTableRowID;
                        dataSearchEntity.calData       = wholeData.calData;
                    }
                }
            }
            #endregion

            #region "宽馏分表和渣油表"
            for (int cutIndex = 0; cutIndex < this._cutMothedEntityList.Count; cutIndex++)
            {
                OilDataSearchColEntity        dataSearchCol      = dataSearchCols.Where(o => o.OilTableName == this._cutMothedEntityList[cutIndex].Name).FirstOrDefault();
                List <OilDataSearchRowEntity> wideDataSearchRows = dataSearchCol.OilDataRowList;
                if (dataSearchCol.OilTableColID > 0)
                {
                    for (int rowIndex = 0; rowIndex < wideDataSearchRows.Count; rowIndex++)
                    {
                        CutDataEntity       cutData          = oilB.CutDataEntityList.Where(o => o.CutName == this._cutMothedEntityList[cutIndex].Name && o.YItemCode == wideDataSearchRows[rowIndex].OilTableRow.itemCode).FirstOrDefault();
                        OilDataSearchEntity dataSearchEntity = dataSearchList.Where(o => o.oilTableColID == dataSearchCol.OilTableColID && o.oilTableRowID == wideDataSearchRows[rowIndex].OilTableRowID).FirstOrDefault();
                        if (dataSearchEntity == null)
                        {
                            if (cutData != null && cutData.CutData != null)
                            {
                                OilDataSearchEntity DataSearch = new OilDataSearchEntity();
                                dataSearchList.Add(DataSearch);
                                DataSearch.oilInfoID     = this._oilB.ID;
                                DataSearch.oilTableColID = dataSearchCol.OilTableColID;
                                DataSearch.oilTableRowID = wideDataSearchRows[rowIndex].OilTableRowID;
                                DataSearch.calData       = cutData.CutData.ToString();
                            }
                        }
                        else if (dataSearchEntity != null && string.IsNullOrWhiteSpace(dataSearchEntity.calData))
                        {
                            if (cutData != null && cutData.CutData != null)
                            {
                                OilDataSearchEntity DataSearch = new OilDataSearchEntity();
                                dataSearchList.Add(DataSearch);
                                DataSearch.oilInfoID     = this._oilB.ID;
                                DataSearch.oilTableColID = dataSearchCol.OilTableColID;
                                DataSearch.oilTableRowID = wideDataSearchRows[rowIndex].OilTableRowID;
                                DataSearch.calData       = cutData.CutData.ToString();
                            }
                        }
                    }
                }
            }
            #endregion

            #endregion
            return(dataSearchList);
        }
コード例 #23
0
        /// <summary>
        /// 导入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripBtnIn_Click(object sender, EventArgs e)
        {
            this.gridList.EndEdit();

            OilInfoAccess oilInfoAccess = new OilInfoAccess();
            LibManageBll  libManageBll  = new LibManageBll();
            string        alert         = "未导入的原油:";

            foreach (DataGridViewRow row in this.gridList.Rows)
            {
                #region
                if (bool.Parse(row.Cells["select"].Value.ToString()) == true)
                {
                    int        oilInfoId  = int.Parse(row.Cells["ID"].Value.ToString());
                    OilInfoOut oilInfoOut = this._outLib.oilInfoOuts.Where(c => c.ID == oilInfoId).FirstOrDefault();

                    OilInfoEntity oilInfoEntity = new OilInfoEntity();
                    libManageBll.toOilInfoEntity(ref oilInfoEntity, oilInfoOut);   //转换为OilInfoEntity
                    oilInfoEntity.ID = OilBll.save(oilInfoEntity);

                    if (oilInfoEntity.ID == -1)
                    {
                        DialogResult r = MessageBox.Show(oilInfoEntity.crudeIndex + "原油已存在!是否要更新", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        if (r == DialogResult.Yes)
                        {
                            oilInfoAccess.Delete("crudeIndex='" + oilInfoEntity.crudeIndex + "'"); //删除原油信息数据
                            oilInfoEntity.ID = OilBll.save(oilInfoEntity);                         //重新插入原油信息

                            libManageBll.toOilDatas(ref oilInfoEntity, oilInfoOut, this._outLib.oilTableRows, this._outLib.oilTableCols);
                            OilBll.saveTables(oilInfoEntity);

                            DatabaseA.FrmOpenA frmOpenA = (DatabaseA.FrmOpenA)GetChildFrm("frmOpenA");
                            if (frmOpenA != null)  //如果打开原油库A的窗口存在,则更新
                            {
                                frmOpenA.refreshGridList(false);
                            }
                        }
                        else
                        {
                            alert += oilInfoEntity.crudeIndex + "  ";
                        }
                    }
                    else
                    {
                        try
                        {
                            libManageBll.toOilDatas(ref oilInfoEntity, oilInfoOut, this._outLib.oilTableRows, this._outLib.oilTableCols);
                            OilBll.saveTables(oilInfoEntity);

                            DatabaseA.FrmOpenA frmOpenA = (DatabaseA.FrmOpenA)GetChildFrm("frmOpenA");
                            if (frmOpenA != null)  //如果打开原油库A的窗口存在,则更新
                            {
                                frmOpenA.refreshGridList(false);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error("原油导入错误!" + ex.ToString());
                            return;
                        }
                        MessageBox.Show(oilInfoEntity.crudeName + "原油导入成功!");
                    }
                }
                #endregion
            }

            if (alert != "未导入的原油:")
            {
                MessageBox.Show(alert, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }