private void txtCode_Leave(object sender, EventArgs e) { //判断编号是否已存在 if (!string.IsNullOrEmpty(this.txtCode.Text.Trim())) { BaseLocationTable LocationCode = new BaseLocationTable(); LocationCode = bLocation.GetModel(txtCode.Text, txtProductCode.Text, txtWarehouseCode.Text); if (LocationCode != null) { txtCode.Focus(); txtCode.Text = ""; MessageBox.Show("编号已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
/// <summary> /// 获得当前选中的数据 /// </summary> private void GetCurrentSelectedTable() { try { string code = dgvData.SelectedRows[0].Cells["CODE"].Value.ToString(); string product_code = dgvData.SelectedRows[0].Cells["PRODUCT_CODE"].Value.ToString(); string warehouse_code = dgvData.SelectedRows[0].Cells["WAREHOUSE_CODE"].Value.ToString(); if (code != "") { _currentLocationTable = bLocation.GetModel(code, product_code, warehouse_code); } } catch (Exception ex) { } if (_currentLocationTable == null || _currentLocationTable.CODE == null || "".Equals(_currentLocationTable.CODE)) { _currentLocationTable = null; } }