private void txtHsCode_Leave(object sender, EventArgs e) { //判断编号是否已存在 if (!string.IsNullOrEmpty(this.txtHsCode.Text.Trim())) { BaseHsCodeTable HsCode = new BaseHsCodeTable(); HsCode = bHsCode.GetModel(txtHsCode.Text); if (HsCode != null) { txtHsCode.Focus(); txtHsCode.Text = ""; MessageBox.Show("编号已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
/// <summary> /// 获得当前选中的数据 /// </summary> private void GetCurrentSelectedTable() { try { string code = dgvData.SelectedRows[0].Cells["HS_CODE"].Value.ToString(); if (code != "") { _currentHsCodeTable = bHsCode.GetModel(code); } } catch (Exception ex) { } if (_currentHsCodeTable == null || _currentHsCodeTable.HS_CODE == null || "".Equals(_currentHsCodeTable.HS_CODE)) { _currentHsCodeTable = null; } }
private void txtHsCode_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtHsCode.Text.Trim())) { BaseHsCodeTable HsCode = new BaseHsCodeTable(); BHsCode bHsCode = new BHsCode(); HsCode = bHsCode.GetModel(this.txtHsCode.Text); if (HsCode == null || "".Equals(HsCode)) { txtHsCode.Focus(); txtHsCode.Text = ""; txtHsName.Text = ""; MessageBox.Show("海关编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { txtHsName.Text = HsCode.HS_NAME; } } }
/// <summary> /// 打开新窗口 /// </summary> private void OpenDialogFrm(int mode) { if (mode == CConstant.MODE_NEW || _currentHsCodeTable != null) { FrmHsCodeDialog frm = new FrmHsCodeDialog(); frm.UserInfo = _userInfo; frm.CurrentHsCodeTable = _currentHsCodeTable; frm.Mode = mode; DialogResult resule = frm.ShowDialog(this); if (resule == DialogResult.OK && isSearch) { Search(this.pgControl.GetCurrentPage()); } frm.Dispose(); } else { //MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } _currentHsCodeTable = null; }
private void btnSave_Click(object sender, EventArgs e) { if (CheckInput()) { if (_currentHsCodeTable == null) { _currentHsCodeTable = new BaseHsCodeTable(); } _currentHsCodeTable.HS_CODE = txtHsCode.Text; _currentHsCodeTable.HS_NAME = txtHsName.Text; _currentHsCodeTable.TAX_RATE = Convert.ToDecimal(txtTaxRate.Text); _currentHsCodeTable.LAST_UPDATE_USER = _userInfo.CODE; try { if (bHsCode.Exists(txtHsCode.Text.Trim())) { bHsCode.Update(_currentHsCodeTable); } else { _currentHsCodeTable.CREATE_USER = _userInfo.CODE; bHsCode.Add(_currentHsCodeTable); } } catch (Exception ex) { //log.error MessageBox.Show(""); return; } result = DialogResult.OK; this.Close(); } }
/// <summary> /// 删除 /// </summary> private void MasterToolBar_DoDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("确定要删除吗?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.OK) { try { GetCurrentSelectedTable(); if (_currentHsCodeTable != null) { bHsCode.Delete(_currentHsCodeTable.HS_CODE); Search(this.pgControl.GetCurrentPage()); } else { MessageBox.Show("请选择正确的行!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show("删除失败,请重试或与系统管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } _currentHsCodeTable = null; } }