private void ReportedDate_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtCurrencyCode.Text.Trim()) && ExchangeDate.Value != null) { BaseExchangeTable exchange = new BaseExchangeTable(); exchange = bExchange.GetModel(CConvert.ToDateTime(ExchangeDate.Value.ToString("yyyy-MM")), txtCurrencyCode.Text); if (exchange != null) { ExchangeDate.Value = DateTime.Now; txtCurrencyCode.Text = ""; ExchangeDate.Focus(); MessageBox.Show("当月此货币汇率已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
/// <summary> /// 获得当前选中的数据 /// </summary> private void GetCurrentSelectedTable() { try { DateTime date = CConvert.ToDateTime(CConvert.ToDateTime(dgvData.SelectedRows[0].Cells["EXCHANGE_DATE"].Value).ToString("yyyy-MM")); string currency = CConvert.ToString(dgvData.SelectedRows[0].Cells["FROM_CURRENCY_CODE"].Value); if (date != null && !string.IsNullOrEmpty(currency)) { _currentExchangeTable = bExchange.GetModel(date, currency); } } catch (Exception ex) { } if (_currentExchangeTable == null || _currentExchangeTable.FROM_CURRENCY_CODE == null || "".Equals(_currentExchangeTable.FROM_CURRENCY_CODE)) { _currentExchangeTable = null; } }
/// <summary> /// 打开新窗口 /// </summary> private void OpenDialogFrm(int mode) { if (mode == CConstant.MODE_NEW || _currentExchangeTable != null) { FrmExchangeDialog frm = new FrmExchangeDialog(); frm.UserInfo = _userInfo; frm.CurrentExchangeTable = _currentExchangeTable; 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); } _currentExchangeTable = null; }
private void btnSave_Click(object sender, EventArgs e) { if (CheckInput()) { if (_currentExchangeTable == null) { _currentExchangeTable = new BaseExchangeTable(); } _currentExchangeTable.EXCHANGE_DATE = CConvert.ToDateTime(ExchangeDate.Value.ToString("yyyy-MM")); _currentExchangeTable.FROM_CURRENCY_CODE = txtCurrencyCode.Text; _currentExchangeTable.TO_CURRENCY_CODE = CConstant.EXCHANGE_CHIAN; _currentExchangeTable.EXCHANGE_RATE = CConvert.ToDecimal(txtExchangeRate.Text); _currentExchangeTable.LAST_UPDATE_USER = _userInfo.CODE; try { if (bExchange.Exists(ExchangeDate.Value, txtCurrencyCode.Text.Trim())) { bExchange.Update(_currentExchangeTable); } else { _currentExchangeTable.CREATE_USER = _userInfo.CODE; bExchange.Add(_currentExchangeTable); } } catch (Exception ex) { //log.error MessageBox.Show(ex.Message); return; } result = DialogResult.OK; this.Close(); } }
private void txtCurrencyCode_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtCurrencyCode.Text.Trim())) { BaseMaster baseMaster = bCommon.GetBaseMaster("CURRENCY", txtCurrencyCode.Text.Trim()); if (baseMaster != null) { txtCurrencyCode.Text = baseMaster.Code; txtCurrencyName.Text = baseMaster.Name; } else { MessageBox.Show("货币不存在.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); txtCurrencyCode.Text = ""; txtCurrencyName.Text = ""; txtCurrencyCode.Focus(); } } else { txtCurrencyName.Text = ""; } if (!string.IsNullOrEmpty(this.txtCurrencyCode.Text.Trim()) && ExchangeDate.Value != null) { BaseExchangeTable exchange = new BaseExchangeTable(); exchange = bExchange.GetModel(CConvert.ToDateTime(ExchangeDate.Value.ToString("yyyy-MM")), txtCurrencyCode.Text); if (exchange != null) { ExchangeDate.Value = DateTime.Now; txtCurrencyCode.Text = ""; ExchangeDate.Focus(); MessageBox.Show("当月此货币汇率已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
/// <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 (_currentExchangeTable != null) { bExchange.Delete(_currentExchangeTable.EXCHANGE_DATE, _currentExchangeTable.FROM_CURRENCY_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); } _currentExchangeTable = null; } }
/// <summary> /// 更新一条数据 /// </summary> public int Update(BaseExchangeTable model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BaseExchangeTable model) { return(dal.Add(model)); }