/// <summary> /// 删除选中的原油 /// </summary> public override void delete() { if (this.gridList.CurrentRow != null) { if (MessageBox.Show("是否要删除!", "信息提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { try { int oilInfoId = int.Parse(this.gridList.CurrentRow.Cells["ID"].Value.ToString()); string frmName = this.gridList.CurrentRow.Cells["原油编号"].Value.ToString() + "A"; OilBll.delete(oilInfoId, LibraryType.LibraryA); //删除数据 this._sqlWhere = "1=1"; dgvHeader.SetMangerDataBaseAColHeader(this.gridList, false); InitGridListBind(false); FrmMain frmMain = (FrmMain)this.MdiParent; if (frmMain == null) { return; } Form from = frmMain.GetChildFrm(frmName); //关闭被删除数据的窗口 if (from != null) { from.Close(); } } catch (Exception ex) { Log.Error("数据管理" + ex); } } } }
/// <summary> /// 删除一条记录 /// </summary> public override void delete() { if (this.gridList.CurrentRow != null) { if (MessageBox.Show("是否要删除!", "信息提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { try { int oilInfoID = this.gridList.CurrentRow != null?int.Parse(this.gridList.CurrentRow.Cells["ID"].Value.ToString()) : -1; string crudeIndex = this.gridList.CurrentRow.Cells["原油编号"].Value.ToString(); string frmName = this.gridList.CurrentRow.Cells["原油编号"].Value.ToString() + "B"; OilBll.delete(oilInfoID, LibraryType.LibraryB); //删除数据 this._sqlWhere = "1=1"; dgvHeader.SetMangerDataBaseBColHeader(this.gridList, Visible); InitGridListBind(false); FrmMain frmMain = (FrmMain)this.MdiParent; if (frmMain == null) { return; } Form from = frmMain.GetChildFrm(frmName); //关闭被删除数据的窗口 if (from != null) { from.Close(); } DatabaseC.FrmOpenC openC = (DatabaseC.FrmOpenC)frmMain.GetChildFrm("FrmOpenC"); if (openC != null) { openC.refreshGridList(); } DatabaseC.FrmOilDataC child = (DatabaseC.FrmOilDataC)frmMain.GetChildFrm(crudeIndex + "C"); if (child != null) { child.Close(); } } catch (Exception ex) { Log.Error("数据管理" + ex); } } } }