Exemple #1
0
        /// <summary>
        /// 关闭窗口时保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmOilDataB_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (this.isChanged == true)
            {
                DialogResult r = MessageBox.Show("是否保存" + this._oilB.crudeIndex + "数据到应用库?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (r == DialogResult.Yes)
                {
                    this.SaveB();
                    FrmMain            frmMain  = (FrmMain)this.MdiParent;
                    DatabaseB.FrmOpenB frmOpenB = (DatabaseB.FrmOpenB)frmMain.GetChildFrm("frmOpenB");
                    if (frmOpenB != null)  //如果打开原油库B的窗口存在,则更新
                    {
                        frmOpenB.refreshGridList(false);
                    }

                    this.isChanged = false;
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// 向B库保存新数据时检查
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
 {
     if (beforSelectTabText == EnumTableType.Info.GetDescription())
     {
         if (!this.gridOilInfoB1.isChanged)
         {
             return;
         }
         if (this.gridOilInfoB1.Save() < 0)
         {
             e.Cancel = true;
             MessageBox.Show("原油信息表中的原油编号为空或重复!必须先填写。", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         else
         {
             DatabaseB.FrmOpenB frmOpenB = (DatabaseB.FrmOpenB)GetChildFrm("frmOpenB");
             if (frmOpenB != null)  //如果打开原油库B的窗口存在,则更新
             {
                 frmOpenB.refreshGridList(false);
             }
         }
     }
 }
Exemple #3
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
                    }
                }
            }
        }