private void txtProduct_Group_Code_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtProduct_Group_Code.Text.Trim())) { BaseProductGroupTable product = new BaseProductGroupTable(); BProductGroup bProduct = new BProductGroup(); product = bProduct.GetModel(this.txtProduct_Group_Code.Text); if (product == null || "".Equals(product)) { txtProduct_Group_Code.Focus(); txtProduct_Group_Code.Text = ""; txtProduct_Group_Name.Text = ""; MessageBox.Show("商品种类不存在!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { txtProduct_Group_Code.Text = product.CODE; txtProduct_Group_Name.Text = product.NAME; } } else { txtProduct_Group_Name.Text = ""; } }
private void txtParentCode_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtParentCode.Text.Trim())) { BaseProductGroupTable ProductGroup = new BaseProductGroupTable(); BProductGroup bProductGroup = new BProductGroup(); ProductGroup = bProductGroup.GetModel(this.txtParentCode.Text); if (ProductGroup == null || "".Equals(ProductGroup)) { txtParentCode.Focus(); txtParentCode.Text = ""; txtParentName.Text = ""; MessageBox.Show("上级商品类别不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { txtParentCode.Text = ProductGroup.CODE; txtParentName.Text = ProductGroup.NAME; txtIndicatesOrder.Focus(); } } else { txtParentName.Text = ""; } }
private void txtCode_Leave(object sender, EventArgs e) { //判断编号是否已存在 if (!string.IsNullOrEmpty(this.txtCode.Text.Trim())) { BaseProductGroupTable ProductGroupCode = new BaseProductGroupTable(); ProductGroupCode = bProductGroup.GetModel(txtCode.Text); if (ProductGroupCode != 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(); if (code != "") { _currentProductGroupTable = bProductGroup.GetModel(code); } } catch (Exception ex) { } if (_currentProductGroupTable == null || _currentProductGroupTable.CODE == null || "".Equals(_currentProductGroupTable.CODE)) { _currentProductGroupTable = null; } }
private void txtGroupCode_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtGroupCode.Text.Trim())) { BaseProductGroupTable productGroup = new BaseProductGroupTable(); BProductGroup bProductGroup = new BProductGroup(); productGroup = bProductGroup.GetModel(this.txtGroupCode.Text); if (productGroup == null || "".Equals(productGroup)) { txtGroupCode.Focus(); txtGroupCode.Text = ""; txtGroupName.Text = ""; MessageBox.Show("类别型号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { txtGroupName.Text = productGroup.NAME; } } }
/// <summary> /// 打开新窗口 /// </summary> private void OpenDialogFrm(int mode) { if (mode == CConstant.MODE_NEW || _currentProductGroupTable != null) { FrmProductGroupDialog frm = new FrmProductGroupDialog(); frm.UserInfo = _userInfo; frm.CurrentProductGroupTable = _currentProductGroupTable; 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); } _currentProductGroupTable = null; }
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 txtGroupCode_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtGroupCode.Text.Trim())) { BaseProductGroupTable productGroup = bProductGroup.GetModel(this.txtGroupCode.Text); if (productGroup != null) { txtGroupName.Text = productGroup.NAME; } else { txtGroupCode.Text = ""; txtGroupName.Text = ""; MessageBox.Show("种类不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); txtGroupCode.Focus(); } } else { txtGroupCode.Text = ""; txtGroupName.Text = ""; } }
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(); } }
/// <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 (_currentProductGroupTable != null) { bProductGroup.Delete(_currentProductGroupTable.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); } _currentProductGroupTable = null; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BaseProductGroupTable model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(BaseProductGroupTable model) { return(dal.Add(model)); }
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 }); }