/// <summary> /// 表格单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void gridCenter_Click(object sender, EventArgs e) { DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hi = this.ViewCenter.CalcHitInfo(((Control)sender).PointToClient(Control.MousePosition)); if (this.ViewCenter != null && this.ViewCenter.FocusedRowHandle >= 0 && hi.RowHandle >= 0) { m_cutRow = this.ViewCenter.FocusedRowHandle; DataRow dw = ViewCenter.GetDataRow(m_cutRow); int MatchCenterID = int.Parse(dw["MatchCenterID"].ToString()); MatchCenter = MatchCenterBLL.GetModel(MatchCenterID); SetTextValue(MatchCenter); SetControlEnAbled(); } }
/// <summary> /// 删除按纽事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Del_Click(object sender, EventArgs e) { try { if (ShowMessageBox.ShowQuestion("确认删除吗?") == DialogResult.No) { return; } DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hi = this.ViewCenter.CalcHitInfo(((Control)sender).PointToClient(Control.MousePosition)); if (this.ViewCenter != null && this.ViewCenter.FocusedRowHandle >= 0) { m_cutRow = this.ViewCenter.FocusedRowHandle; DataRow dw = ViewCenter.GetDataRow(m_cutRow); int MatchCenterID = int.Parse(dw["MatchCenterID"].ToString()); ManagementCenter.BLL.RC_MatchMachineBLL _MatchMachineBLL = new RC_MatchMachineBLL(); DataSet ds = _MatchMachineBLL.GetList(string.Format("MatchCenterID={0}", MatchCenterID)); if (ds != null && ds.Tables[0].Rows.Count > 0) { ShowMessageBox.ShowInformation("该中心下存在撮合机,不允许删除!"); return; } MatchCenterBLL.Delete(MatchCenterID); ShowMessageBox.ShowInformation("删除成功!"); SetTextValue(null); SetControlEnAbled(); LoadCenterList(); } } catch (Exception ex) { ShowMessageBox.ShowInformation("删除失败!"); string errCode = "GL-2002"; string errMsg = "删除失败"; VTException vte = new VTException(errCode, errMsg, ex); LogHelper.WriteError(vte.ToString(), vte.InnerException); } SetTextValue(null); SetControlEnAbled(); }
/// <summary> /// 设置控件的值 /// </summary> /// <param name="matchcenter"></param> private void SetTextValue(RC_MatchCenter matchcenter) { if (matchcenter == null) { m_cutRow = this.ViewCenter.FocusedRowHandle; DataRow dw = ViewCenter.GetDataRow(m_cutRow); if (dw == null) { return; } int MatchCenterID = int.Parse(dw["MatchCenterID"].ToString()); matchcenter = MatchCenterBLL.GetModel(MatchCenterID); if (matchcenter == null) { return; } } this.txt_CenterIP.Text = matchcenter.IP; this.txt_CenterName.Text = matchcenter.MatchCenterName; this.txt_cuoheService.Text = matchcenter.CuoHeService; this.txt_Port.Text = matchcenter.Port.ToString(); this.txt_xiadanService.Text = matchcenter.XiaDanService; this.txt_CenterID.Text = matchcenter.MatchCenterID.ToString(); }