protected string CheckCurrency(string currencyCode, string title) { if (currencyCode == null || "".Equals(currencyCode.ToString())) { return(title + ERROR_NULL); } if (_currencyTable[currencyCode] != null) { return(""); } BCurrency bCurrency = new BCurrency(); if (bCurrency.Exists(currencyCode)) { _currencyTable.Add(currencyCode, currencyCode); return(""); } return(title + ERROR_EXIST); }
protected string CheckWarehouse(string warehouseCode, string title) { if (warehouseCode == null || "".Equals(warehouseCode.ToString())) { return(title + ERROR_NULL); } if (_wasehouseTable[warehouseCode] != null) { return(""); } BCurrency bCurrency = new BCurrency(); if (bCurrency.Exists(warehouseCode)) { _wasehouseTable.Add(warehouseCode, warehouseCode); return(""); } return(title + ERROR_EXIST); }
private void txtCurrencyCode_Leave(object sender, EventArgs e) { //判断编号是否已存在 if (!string.IsNullOrEmpty(this.txtCurrencyCode.Text.Trim())) { BaseCurrencyTable Currency = new BaseCurrencyTable(); BCurrency bCurrency = new BCurrency(); Currency = bCurrency.GetModel(txtCurrencyCode.Text); if (Currency == null) { txtCurrencyCode.Focus(); txtCurrencyCode.Text = ""; txtCurrencyName.Text = ""; MessageBox.Show("货币编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { txtCurrencyName.Text = Currency.NAME; } } }
public override string[] doUpdateDB() { BaseCurrencyTable CurrencyTable = null; BCurrency bCurrency = new BCurrency(); StringBuilder strError = new StringBuilder(); int successData = 0; int failureData = 0; string errorFilePath = ""; string backupFilePath = ""; //数据导入处理 foreach (DataRow dr in _csvDataTable.Rows) { StringBuilder str = new StringBuilder(); //编号 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CODE")))) { str.Append(CheckString(GetValue(dr, "CODE"), 20, "编号")); } else { str.Append("编号不能为空!"); } //名称 str.Append(CheckLenght(GetValue(dr, "NAME"), 100, "名称")); //状态 str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS), 9, "状态")); if (str.ToString().Trim().Length > 0) { strError.Append(GetStringBuilder(dr, str.ToString().Trim())); failureData++; continue; } try { CurrencyTable = new BaseCurrencyTable(); CurrencyTable.CODE = CConvert.ToString(GetValue(dr, "CODE")); CurrencyTable.NAME = CConvert.ToString(GetValue(dr, "NAME")); CurrencyTable.CREATE_USER = _userInfo.CODE; CurrencyTable.LAST_UPDATE_USER = _userInfo.CODE; CurrencyTable.STATUS_FLAG = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS)); if (!bCurrency.Exists(CurrencyTable.CODE)) { bCurrency.Add(CurrencyTable); } else { bCurrency.Update(CurrencyTable); } successData++; } catch { strError.Append(GetStringBuilder(dr, " 数据导入失败,请与系统管理员联系!").ToString()); failureData++; } } //错误记录处理 if (strError.Length > 0) { errorFilePath = WriteFile(strError.ToString()); } //备份处理 backupFilePath = BackupFile(); return(new string[] { successData.ToString(), failureData.ToString(), errorFilePath, backupFilePath }); }