Ejemplo n.º 1
0
        /// <summary>
        /// 表格控件绑定
        /// </summary>
        private void GridListBind()
        {
            dgvHeader.SetMangerDataBaseBColHeader(this.gridList, false, true);
            this.gridList.Rows.Clear();
            OilInfoBAccess         access  = new OilInfoBAccess();
            IList <OilInfoBEntity> oilInfo = access.Get(_sqlWhere);

            //绑定数据
            for (int i = 0; i < oilInfo.Count; i++)
            {
                string receiveDate = oilInfo[i].receiveDate == null ? string.Empty : oilInfo[i].receiveDate.Value.ToString(dateFormat);
                string updataDate  = string.Empty;
                if (oilInfo[i].updataDate != string.Empty)
                {
                    var updataDateTime = oilDataCheck.GetDate(oilInfo[i].updataDate);
                    updataDate = updataDateTime == null ? string.Empty : updataDateTime.Value.ToString(LongDateFormat);
                }
                this.gridList.Rows.Add
                    (false, i, oilInfo[i].ID, 0,
                    oilInfo[i].crudeName,
                    oilInfo[i].englishName,
                    oilInfo[i].crudeIndex,
                    oilInfo[i].country,
                    oilInfo[i].region,
                    receiveDate, updataDate,
                    oilInfo[i].sourceRef,
                    oilInfo[i].type,
                    oilInfo[i].classification,
                    oilInfo[i].sulfurLevel,
                    oilInfo[i].acidLevel
                    );
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 显示相似查找的基础值
        /// </summary>
        /// <param name="oil"></param>
        private void selectOilData()
        {
            string crudeIndex = this.gridList.CurrentRow != null ? this.gridList.CurrentRow.Cells["原油编号"].Value.ToString() : string.Empty;

            OilInfoBAccess oilInfoB     = new OilInfoBAccess();
            OilInfoBEntity tempOilInfoB = oilInfoB.Get("crudeIndex = '" + crudeIndex + "'").FirstOrDefault();

            if (tempOilInfoB == null)
            {
                return;
            }

            int oilInfoID = tempOilInfoB.ID;
            OilTableRowEntity selectOiltableRowEntity = (OilTableRowEntity)cmbSimilarItem.SelectedItem;         //获取物性下拉菜单选择项实体
            int oilTableRowID = selectOiltableRowEntity.ID;
            OilDataSearchColEntity selectedItem = (OilDataSearchColEntity)this.cmbSimilarFraction.SelectedItem; //确定当前菜单中的数据
            int oilTableColID = selectedItem.OilTableColID;

            OilDataSearchAccess oilDataSearchAccess = new OilDataSearchAccess();
            OilDataSearchEntity oilData             = oilDataSearchAccess.Get("oilInfoID = " + oilInfoID + " and oilTableColID = " + oilTableColID + " and oilTableRowID =" + oilTableRowID).FirstOrDefault();

            if (oilData != null)
            {
                if (oilData.calData != string.Empty && oilData.calData != "非数字" && oilData.calData != "正无穷大" && oilData.calData != "负无穷大")
                {
                    float temp = 0;
                    if (float.TryParse(oilData.calData, out temp))
                    {
                        this.txtSimilarFoundationValue.Text = oilData.calData;
                    }
                    else
                    {
                        this.txtSimilarFoundationValue.Text = string.Empty;
                    }
                }
                else
                {
                    this.txtSimilarFoundationValue.Text = string.Empty;
                }
            }
            else
            {
                this.txtSimilarFoundationValue.Text = string.Empty;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 向B库中保存A库的原油信息
        /// </summary>
        /// <returns></returns>
        public int SaveInfoB(ref OilInfoBEntity oilInfoB)
        {
            ReadDataFromUI();

            OilBll.InfoToInfoB(this._oilInfo, oilInfoB);

            oilInfoB.ID = OilBll.saveInfo(oilInfoB);

            if (oilInfoB.ID == -1)
            {
                OilInfoBAccess        access       = new OilInfoBAccess();
                string                sqlWhere     = "crudeIndex='" + oilInfoB.crudeIndex + "'";
                List <OilInfoBEntity> oilInfoBList = access.Get(sqlWhere).ToList();
                oilInfoB.ID = oilInfoBList[0].ID;
                access.Update(oilInfoB, oilInfoB.ID.ToString());
                OilDataBAccess oilDataAccess = new OilDataBAccess();
                oilDataAccess.Delete("labData='' and calData='' and oilInfoID=" + oilInfoB.ID); //删除空的数据
                return(oilInfoB.ID);
            }
            return(oilInfoB.ID);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取到用户选择的OilInfo
        /// </summary>
        /// <returns>用户选择的OilInfoBEntity的集合</returns>
        private List <OilInfoBEntity> getSelectedOil()
        {
            this.gridList.EndEdit();

            List <OilInfoBEntity> result = new List <OilInfoBEntity>();
            OilInfoBAccess        access = new OilInfoBAccess();
            int oilInfoId = -1;

            foreach (DataGridViewRow row in this.gridList.Rows)
            {
                if (row.Cells["select"].Value != null && bool.Parse(row.Cells["select"].Value.ToString()) == true)
                {
                    oilInfoId = int.Parse(row.Cells["ID"].Value.ToString());
                    OilInfoBEntity oilEntity = access.Get(oilInfoId);
                    if (null != oilEntity)
                    {
                        result.Add(oilEntity);
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 关闭窗体的保存提示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmOilDataC_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (IsChange())
            {
                DialogResult r = MessageBox.Show("是否保存数据!", "提示信息", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
                if (r == DialogResult.Yes)
                {
                    this.SaveC();

                    if (this._isValueChange)
                    {
                        var oilInfoB = new OilInfoBAccess().Get(this._oilInfoID);
                        oilInfoB.updataDate = DateTime.Now.ToString(LongDateFormat);
                        OilBll.updateOilInfoB(oilInfoB);

                        FrmMain  frmMain  = (FrmMain)this.MdiParent;
                        FrmOpenC frmOpenC = (FrmOpenC)frmMain.GetChildFrm("frmOpenC");
                        if (frmOpenC != null)  //如果打开原油库A的窗口存在,则更新
                        {
                            frmOpenC.refreshGridList();
                        }
                        this._isValueChange = false;
                    }

                    this._isChange = false;
                }
                else if (r == DialogResult.No)
                {
                    this._isChange = false;
                }
                else if (r == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolStripMenuItemExportXml_Click(object sender, EventArgs e)
        {
            var gv = contextMenuStrip1.Tag as DataGridView;

            if (gv == null)
            {
                return;
            }
            var row = gv.CurrentRow;// gv.SelectedRows.Count > 0 ? gv.SelectedRows[0] : null;

            if (row == null)
            {
                return;
            }

            var id = (int?)row.Cells["ID"].Value;

            if (id == null)
            {
                return;
            }

            OilInfoBAccess access = new OilInfoBAccess();
            var            oil    = access.Get(id.Value);

            saveXmlFileDialog1.FileName = $"{oil.crudeIndex} - {oil.englishName ?? oil.crudeName}";
            if (saveXmlFileDialog1.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            var r   = RefineryAssays.ConvertFrom(oil);
            var xml = r.ToXml();

            File.WriteAllText(saveXmlFileDialog1.FileName, xml);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// B库数据导入功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripBtnIn_Click(object sender, EventArgs e)
        {
            this.dgvLibBIn.EndEdit();
            OilInfoBAccess oilInfoBccess = new OilInfoBAccess(); //从B库进行原油查找
            LibManageBll   libManageBll  = new LibManageBll();   //导入B库管理
            string         alert         = "未导入的原油:";

            foreach (DataGridViewRow row in this.dgvLibBIn.Rows)
            {
                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();//从库文件中获取数据

                    OilInfoBEntity oilInfoBEntity = new OilInfoBEntity();
                    libManageBll.toOilInfoEntity(ref oilInfoBEntity, oilInfoOut); //转换为OilInfoBEntity
                    oilInfoBEntity.ID = OilBll.saveInfo(oilInfoBEntity);          //将数据保存到原油应用模块

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

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

                            libManageBll.toOilDataSearchs(ref oilInfoBEntity, oilInfoOut);
                            OilBll.saveSearchTable(oilInfoBEntity);

                            libManageBll.toCurve(ref oilInfoBEntity, oilInfoOut.curves, _outLib.curveTypes);
                            OilBll.saveCurves(oilInfoBEntity);


                            if (this.ActiveMdiChild != null)
                            {
                                if (this.ActiveMdiChild.GetType().Name == "FrmMain")//如果打开窗体存在.
                                {
                                    FrmMain frmMain = (FrmMain)this.ActiveMdiChild;
                                    if (frmMain != null)  //如果打开原油库A的窗口存在,则更新
                                    {
                                        frmMain.refreshGridList();
                                    }
                                }
                            }
                            MessageBox.Show(oilInfoBEntity.crudeName + "原油导入成功!");
                        }
                        else
                        {
                            alert += oilInfoBEntity.crudeIndex + "  ";
                            MessageBox.Show(oilInfoBEntity.crudeName + "原油导入不成功!");
                        }
                    }
                    else//原油不存在
                    {
                        try
                        {
                            libManageBll.toOilDatas(ref oilInfoBEntity, oilInfoOut, this._outLib.oilTableRows, this._outLib.oilTableCols);
                            OilBll.saveTables(oilInfoBEntity);

                            libManageBll.toOilDataSearchs(ref oilInfoBEntity, oilInfoOut);
                            OilBll.saveSearchTable(oilInfoBEntity);

                            libManageBll.toCurve(ref oilInfoBEntity, oilInfoOut.curves, _outLib.curveTypes);
                            OilBll.saveCurves(oilInfoBEntity);


                            if (this.ActiveMdiChild != null)
                            {
                                if (this.ActiveMdiChild.GetType().Name == "FrmMain")//如果打开窗体存在.
                                {
                                    FrmMain frmMain = (FrmMain)this.ActiveMdiChild;
                                    if (frmMain != null)  //如果打开原油库A的窗口存在,则更新
                                    {
                                        frmMain.refreshGridList();
                                    }
                                }
                            }
                            MessageBox.Show(oilInfoBEntity.crudeName + "原油导入成功!");
                        }
                        catch (Exception ex)
                        {
                            Log.Error("原油导入错误!" + ex.ToString());
                            MessageBox.Show(oilInfoBEntity.crudeName + "原油导入不成功!");
                            return;
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 导入到B库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripBtnIn_Click(object sender, EventArgs e)
        {
            this.gridList.EndEdit();
            OilInfoBAccess oilInfoAccess = new OilInfoBAccess();
            LibManageBll   libManageBll  = new LibManageBll();
            string         alert         = "未导入的原油:";

            foreach (DataGridViewRow row in this.gridList.Rows)
            {
                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();

                    OilInfoBEntity oilInfoBEntity = new OilInfoBEntity();
                    libManageBll.toOilInfoEntity(ref oilInfoBEntity, oilInfoOut);   //转换为OilInfoEntity
                    oilInfoBEntity.ID = OilBll.saveInfo(oilInfoBEntity);

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

                                libManageBll.toOilDatas(ref oilInfoBEntity, oilInfoOut, this._outLib.oilTableRows, this._outLib.oilTableCols);
                                OilBll.saveTables(oilInfoBEntity);
                                libManageBll.toCurve(ref oilInfoBEntity, oilInfoOut.curves, _outLib.curveTypes);
                                OilBll.saveCurves(oilInfoBEntity);
                                libManageBll.toOilDataSearchs(ref oilInfoBEntity, oilInfoOut);
                                OilBll.saveSearchTable(oilInfoBEntity.OilDataSearchs);

                                DatabaseB.FrmOpenB frmOpenB = (DatabaseB.FrmOpenB)GetChildFrm("frmOpenB");
                                if (frmOpenB != null)  //如果打开原油库B的窗口存在,则更新
                                {
                                    frmOpenB.refreshGridList(false);
                                }

                                DatabaseC.FrmOpenC frmOpenC = (DatabaseC.FrmOpenC)GetChildFrm("frmOpenC");
                                if (frmOpenC != null)  //如果打开原油库C的窗口存在,则更新
                                {
                                    frmOpenC.refreshGridList();
                                }
                            }
                            else
                            {
                                alert += oilInfoBEntity.crudeIndex + "  ";
                            }
                            #endregion
                        }
                        catch (Exception ex)
                        {
                            Log.Error("原油导入错误!" + ex.ToString());
                            return;
                        }

                        MessageBox.Show(oilInfoBEntity.crudeName + "原油导入成功!");
                    }
                    else
                    {
                        #region "原油无冲突"
                        try
                        {
                            libManageBll.toOilDatas(ref oilInfoBEntity, oilInfoOut, this._outLib.oilTableRows, this._outLib.oilTableCols);
                            OilBll.saveTables(oilInfoBEntity);
                            libManageBll.toCurve(ref oilInfoBEntity, oilInfoOut.curves, _outLib.curveTypes);
                            OilBll.saveCurves(oilInfoBEntity);
                            libManageBll.toOilDataSearchs(ref oilInfoBEntity, oilInfoOut);
                            OilBll.saveSearchTable(oilInfoBEntity.OilDataSearchs);

                            DatabaseB.FrmOpenB frmOpenB = (DatabaseB.FrmOpenB)GetChildFrm("frmOpenB");
                            if (frmOpenB != null)  //如果打开原油库A的窗口存在,则更新
                            {
                                frmOpenB.refreshGridList(false);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error("原油导入错误!" + ex.ToString());
                            return;
                        }

                        MessageBox.Show(oilInfoBEntity.crudeName + "原油导入成功!");

                        #endregion
                    }
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 表格控件绑定
        /// </summary>
        public void InitGridListBind()
        {
            dgvHeader.SetAppDataBaseBColHeader(this.gridList);

            OilInfoBAccess         acess   = new OilInfoBAccess();
            IList <OilInfoBEntity> oilInfo = acess.Get(this._sqlWhere);

            OilDataSearchAccess dataSearchAccess = new OilDataSearchAccess();

            //绑定数据
            for (int i = 0; i < oilInfo.Count; i++)
            {
                List <OilDataSearchEntity> dataList = dataSearchAccess.Get("oilInfoID =" + oilInfo[i].ID).ToList();
                if (dataList.Count > 0)
                {
                    List <OilDataSearchEntity> oilinfoDataList = dataList.Where(o => o.OilTableTypeID == (int)EnumTableType.Info).ToList();
                    #region "日期处理"
                    string receiveDate = oilInfo[i].receiveDate == null ? string.Empty : oilInfo[i].receiveDate.Value.ToString(dateFormat);
                    string updataDate  = string.Empty;
                    if (oilInfo[i].updataDate != string.Empty)
                    {
                        var updataDateTime = oilDataCheck.GetDate(oilInfo[i].updataDate);
                        updataDate = updataDateTime == null ? string.Empty : updataDateTime.Value.ToString(LongDateFormat);
                    }
                    #endregion
                    int rowIndex = this.gridList.Rows.Add();
                    this.gridList.Rows[rowIndex].Cells["ID"].Value = oilInfo[i].ID;
                    foreach (var data in oilinfoDataList)
                    {
                        switch (data.OilTableRow.itemCode)
                        {
                        case "CNA":
                            this.gridList.Rows[rowIndex].Cells["原油名称"].Value = data.calData;
                            break;

                        case "ENA":
                            this.gridList.Rows[rowIndex].Cells["英文名称"].Value = data.calData;
                            break;

                        case "IDC":
                            this.gridList.Rows[rowIndex].Cells["原油编号"].Value = data.calData;
                            break;

                        case "COU":
                            this.gridList.Rows[rowIndex].Cells["产地国家"].Value = data.calData;
                            break;

                        case "GRC":
                            this.gridList.Rows[rowIndex].Cells["地理区域"].Value = data.calData;
                            break;


                        case "ADA":
                            this.gridList.Rows[rowIndex].Cells["评价日期"].Value = data.calData;
                            break;

                        case "UDD":
                            this.gridList.Rows[rowIndex].Cells["入库日期"].Value = data.calData;
                            break;

                        case "SR":
                            this.gridList.Rows[rowIndex].Cells["数据来源"].Value = data.calData;
                            break;

                        case "CLA":
                            this.gridList.Rows[rowIndex].Cells["类别"].Value = data.calData;
                            break;


                        case "TYP":
                            this.gridList.Rows[rowIndex].Cells["基属"].Value = data.calData;
                            break;

                        case "SCL":
                            this.gridList.Rows[rowIndex].Cells["硫水平"].Value = data.calData;
                            break;

                        case "ACL":
                            this.gridList.Rows[rowIndex].Cells["酸水平"].Value = data.calData;
                            break;
                        }
                    }
                    //this.gridList.Rows.Add(
                    //            oilInfo[i].ID,
                    //            oilInfo[i].crudeName,
                    //            oilInfo[i].englishName,
                    //            oilInfo[i].crudeIndex,
                    //            oilInfo[i].country,
                    //            oilInfo[i].region,
                    //            receiveDate,
                    //            updataDate,
                    //            oilInfo[i].sourceRef,
                    //            oilInfo[i].type,
                    //            oilInfo[i].classification,
                    //            oilInfo[i].sulfurLevel,
                    //            oilInfo[i].acidLevel);
                }
            }
            //lbResult.Text = "共有" + oilInfo.Count.ToString() + "条信息满足条件。";
        }