protected string CheckProductGroup(string productGroup, string title) { if ((productGroup == null || "".Equals(productGroup.ToString()))) { return(title + ERROR_NULL); } BProductGroup bProductGroup = new BProductGroup(); if (bProductGroup.Exists(productGroup)) { return(""); } return(title + ERROR_EXIST); }
private void btnSave_Click(object sender, EventArgs e) { if (CheckInput()) { if (_currentProductGroupTable == null) { _currentProductGroupTable = new BaseProductGroupTable(); } _currentProductGroupTable.CODE = txtCode.Text.Trim(); _currentProductGroupTable.NAME = txtName.Text.Trim(); _currentProductGroupTable.PARENT_CODE = txtParentCode.Text.Trim(); _currentProductGroupTable.LAST_UPDATE_USER = _userInfo.CODE.Trim(); _currentProductGroupTable.BASIC_SUPPLIER = txtSupplierCode.Text.Trim(); _currentProductGroupTable.SECOND_SUPPLIER_CODE = txtSecondSupplier.Text.Trim(); _currentProductGroupTable.THIRD_SUPPLIER_CODE = txtthirdSupplier.Text.Trim(); _currentProductGroupTable.LAST_UPDATE_USER = _userInfo.CODE; try { if (bProductGroup.Exists(txtCode.Text.Trim())) { bProductGroup.Update(_currentProductGroupTable); } else { _currentProductGroupTable.CREATE_USER = _userInfo.CODE; bProductGroup.Add(_currentProductGroupTable); } } catch (Exception ex) { //log.error MessageBox.Show(""); return; } result = DialogResult.OK; this.Close(); } }
private void btnSave_Click(object sender, EventArgs e) { if (CheckInput()) { if (_currentProductGroupTable == null) { _currentProductGroupTable = new BaseProductGroupTable(); } _currentProductGroupTable.CODE = txtCode.Text; _currentProductGroupTable.NAME = txtName.Text; _currentProductGroupTable.PARENT_CODE = txtParentCode.Text; _currentProductGroupTable.LAST_UPDATE_USER = _userInfo.CODE; _currentProductGroupTable.INDICATES_ORDER = CConvert.ToInt32(txtIndicatesOrder.Text); try { if (bProductGroup.Exists(txtCode.Text.Trim())) { bProductGroup.Update(_currentProductGroupTable); } else { _currentProductGroupTable.CREATE_USER = _userInfo.CODE; bProductGroup.Add(_currentProductGroupTable); } } catch (Exception ex) { //log.error MessageBox.Show(""); return; } result = DialogResult.OK; this.Close(); } }
public override string[] doUpdateDB() { BaseProductGroupTable productGroupTable = null; BProductGroup bProductGroup = new BProductGroup(); 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, "名称")); //上级名称 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "PARENT_CODE")))) { str.Append(CheckProductGroup(CConvert.ToString(GetValue(dr, "PARENT_CODE")), "上级名称")); } //表示顺序 str.Append(CheckLenght(GetValue(dr, "INDICATES_ORDER"), 1000000, "表示顺序")); //状态 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 { productGroupTable = new BaseProductGroupTable(); productGroupTable.CODE = CConvert.ToString(GetValue(dr, "CODE")); productGroupTable.NAME = CConvert.ToString(GetValue(dr, "NAME")); productGroupTable.PARENT_CODE = CConvert.ToString(GetValue(dr, "PARENT_CODE")); productGroupTable.INDICATES_ORDER = CConvert.ToInt32(GetValue(dr, "INDICATES_ORDER", 0)); productGroupTable.STATUS_FLAG = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS)); productGroupTable.CREATE_USER = _userInfo.CODE; productGroupTable.LAST_UPDATE_USER = _userInfo.CODE; if (!bProductGroup.Exists(productGroupTable.CODE)) { bProductGroup.Add(productGroupTable); } else { bProductGroup.Update(productGroupTable); } 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 }); }
public override string[] doUpdateDB() { BaseProductGroupTable productGroupTable = null; BProductGroup bProductGroup = new BProductGroup(); 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, "名称")); //上级名称 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "PARENT_CODE")))) { str.Append(CheckProductGroup(CConvert.ToString(GetValue(dr, "PARENT_CODE")), "上级名称")); } //默认供应商 str.Append(CheckSupplier(CConvert.ToString(GetValue(dr, "BASIC_SUPPLIER")), "默认供应商")); //供应商2 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "SECOND_SUPPLIER_CODE")))) { str.Append(CheckSupplier(CConvert.ToString(GetValue(dr, "SECOND_SUPPLIER_CODE")), "供应商2")); } //供应商3 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "THIRD_SUPPLIER_CODE")))) { str.Append(CheckSupplier(CConvert.ToString(GetValue(dr, "THIRD_SUPPLIER_CODE")), "供应商3")); } if (str.ToString().Trim().Length > 0) { strError.Append(GetStringBuilder(dr, str.ToString().Trim())); failureData++; continue; } try { productGroupTable = new BaseProductGroupTable(); productGroupTable.CODE = CConvert.ToString(GetValue(dr, "CODE")); productGroupTable.NAME = CConvert.ToString(GetValue(dr, "NAME")); productGroupTable.PARENT_CODE = CConvert.ToString(GetValue(dr, "PARENT_CODE")); productGroupTable.BASIC_SUPPLIER = CConvert.ToString(GetValue(dr, "BASIC_SUPPLIER")); productGroupTable.SECOND_SUPPLIER_CODE = CConvert.ToString(GetValue(dr, "SECOND_SUPPLIER_CODE")); productGroupTable.THIRD_SUPPLIER_CODE = CConvert.ToString(GetValue(dr, "THIRD_SUPPLIER_CODE")); productGroupTable.STATUS_FLAG = CConstant.INIT; productGroupTable.CREATE_USER = _userInfo.CODE; productGroupTable.LAST_UPDATE_USER = _userInfo.CODE; if (!bProductGroup.Exists(productGroupTable.CODE)) { bProductGroup.Add(productGroupTable); } else { bProductGroup.Update(productGroupTable); } 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 }); }