private void txtId_Leave(object sender, EventArgs e) { //判断编号是否已存在 if (!string.IsNullOrEmpty(this.txtId.Text.Trim())) { BaseBankTable bankCode = new BaseBankTable(); bankCode = bBank.GetModel(txtId.Text.Trim()); if (bankCode != null) { txtId.Focus(); txtId.Text = ""; MessageBox.Show("编号已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
/// <summary> /// 获得当前选中的数据 /// </summary> private void GetCurrentSelectedTable() { try { string code = dgvData.SelectedRows[0].Cells["ID"].Value.ToString(); if (code != "") { _currentBankTable = bBank.GetModel(code); } } catch (Exception ex) { } if (_currentBankTable == null || _currentBankTable.ID == null || "".Equals(_currentBankTable.ID)) { _currentBankTable = null; } }