Esempio n. 1
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;
                        }
                    }
                }
            }
        }
Esempio n. 2
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
                    }
                }
            }
        }