private void txtSupplierCode_Leave(object sender, EventArgs e) { //判断编号是否已存在 if (!string.IsNullOrEmpty(this.txtSupplierCode.Text.Trim()) && !string.IsNullOrEmpty(this.txtProductCode.Text.Trim()) && !string.IsNullOrEmpty(this.txtUnitCode.Text.Trim())) { BaseSupplierPriceTable SupplierPriceCode = new BaseSupplierPriceTable(); SupplierPriceCode = bSupplierPrice.GetModel(txtSupplierCode.Text, txtProductCode.Text, txtUnitCode.Text, CConstant.EXCHANGE_RMB); if (SupplierPriceCode != null) { txtSupplierCode.Text = ""; txtSupplierName.Text = ""; txtProductCode.Text = ""; txtProductName.Text = ""; txtUnitCode.Text = ""; txtUnitName.Text = ""; txtSupplierCode.Focus(); MessageBox.Show("供应商编号商品编号单位编号货币编号的组合\r\n已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } string supplier = txtSupplierCode.Text.Trim(); if (!string.IsNullOrEmpty(supplier)) { BaseMaster baseMaster = bCommon.GetBaseMaster("SUPPLIER", supplier); if (baseMaster != null) { txtSupplierCode.Text = baseMaster.Code; txtSupplierName.Text = baseMaster.Name; txtProductCode.Focus(); } else { MessageBox.Show("供应商编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSupplierCode.Text = ""; txtSupplierName.Text = ""; txtSupplierCode.Focus(); } } else { txtSupplierName.Text = ""; } }
private void btnSave_Click_1(object sender, EventArgs e) { if (!CheckCode()) { return; } if (CheckInput()) { if (_currentSupplierPriceTable == null) { _currentSupplierPriceTable = new BaseSupplierPriceTable(); } _currentSupplierPriceTable.SUPPLIER_CODE = txtSupplierCode.Text.Trim(); _currentSupplierPriceTable.PRODUCT_CODE = txtProductCode.Text.Trim(); _currentSupplierPriceTable.UNIT_CODE = txtUnitCode.Text; _currentSupplierPriceTable.CURRENCY_CODE = CConstant.EXCHANGE_CHIAN; _currentSupplierPriceTable.PRICE = Convert.ToDecimal(txtPrice.Text.Trim()); _currentSupplierPriceTable.LAST_UPDATE_USER = _userInfo.CODE; try { if (bSupplierPrice.Exists(txtSupplierCode.Text.Trim(), txtProductCode.Text.Trim(), txtUnitCode.Text.Trim(), CConstant.EXCHANGE_CHIAN)) { bSupplierPrice.Update(_currentSupplierPriceTable); } else { _currentSupplierPriceTable.CREATE_USER = _userInfo.CODE; bSupplierPrice.Add(_currentSupplierPriceTable); } } catch (Exception ex) { //log.error MessageBox.Show(""); return; } result = DialogResult.OK; this.Close(); } }
/// <summary> /// 获得当前选中的数据 /// </summary> private void GetCurrentSelectedTable() { try { string suppliercode = dgvData.SelectedRows[0].Cells["SUPPLIER_CODE"].Value.ToString(); string productcode = dgvData.SelectedRows[0].Cells["PRODUCT_CODE"].Value.ToString(); string unitcode = dgvData.SelectedRows[0].Cells["UNIT_CODE"].Value.ToString(); if (suppliercode != "") { _currentSupplierPriceTable = bSupplierPrice.GetModel(suppliercode, productcode, unitcode, CConstant.EXCHANGE_CHIAN); } } catch (Exception ex) { } if (_currentSupplierPriceTable == null || _currentSupplierPriceTable.SUPPLIER_CODE == null || "".Equals(_currentSupplierPriceTable.SUPPLIER_CODE)) { _currentSupplierPriceTable = null; } }
/// <summary> /// 打开新窗口 /// </summary> private void OpenDialogFrm(int mode) { if (mode == CConstant.MODE_NEW || _currentSupplierPriceTable != null) { FrmSupplierPriceDialog frm = new FrmSupplierPriceDialog(); frm.UserInfo = _userInfo; frm.CurrentSupplierPriceTable = _currentSupplierPriceTable; 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); } _currentSupplierPriceTable = null; }
private bool CheckCode() { //判断编号是否已存在 if (!string.IsNullOrEmpty(this.txtSupplierCode.Text.Trim()) && !string.IsNullOrEmpty(this.txtProductCode.Text.Trim()) && !string.IsNullOrEmpty(this.txtUnitCode.Text.Trim())) { BaseSupplierPriceTable SupplierPriceCode = new BaseSupplierPriceTable(); SupplierPriceCode = bSupplierPrice.GetModel(txtSupplierCode.Text, txtProductCode.Text, txtUnitCode.Text, CConstant.EXCHANGE_CHIAN); if (SupplierPriceCode != null) { txtSupplierCode.Text = ""; txtSupplierName.Text = ""; txtProductCode.Text = ""; txtProductName.Text = ""; txtUnitCode.Text = ""; txtUnitName.Text = ""; txtSupplierCode.Focus(); MessageBox.Show("供应商编号商品编号单位编号货币编号的组合\r\n已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } } return(true); }
/// <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 (_currentSupplierPriceTable != null) { bSupplierPrice.Delete(_currentSupplierPriceTable.SUPPLIER_CODE, _currentSupplierPriceTable.PRODUCT_CODE, _currentSupplierPriceTable.UNIT_CODE, _currentSupplierPriceTable.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); } _currentSupplierPriceTable = null; } }
public override string[] doUpdateDB() { BaseSupplierPriceTable SupplierPriceTable = null; BSupplierPrice bSupplierPrice = new BSupplierPrice(); StringBuilder strError = new StringBuilder(); int successData = 0; int failureData = 0; string errorFilePath = ""; string backupFilePath = ""; //数据导入处理 foreach (DataRow dr in _csvDataTable.Rows) { StringBuilder str = new StringBuilder(); //供应商编号 str.Append(CheckSupplier(CConvert.ToString(GetValue(dr, "SUPPLIER_CODE")), "供应商编号")); //商品编号 if (CConvert.ToString(GetValue(dr, "PRODUCT_CODE")).Length > 20) { string product = GetValue(dr, "PRODUCT_CODE").ToString().Substring(0, 20); str.Append(CheckProduct(product, "商品编号")); } else { str.Append(CheckProduct(CConvert.ToString(GetValue(dr, "PRODUCT_CODE")), "商品编号")); } //单位 str.Append(CheckUnit(CConvert.ToString(GetValue(dr, "UNIT_CODE")), "单位")); //货币 str.Append(CheckCurrency(CConvert.ToString(GetValue(dr, "CURRENCY_CODE")), "货币")); //单价 str.Append(CheckDecimal(GetValue(dr, "PRICE", 0), 12, 3, "单价")); //状态 str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL), 9, "状态")); if (str.ToString().Trim().Length > 0) { strError.Append(GetStringBuilder(dr, str.ToString().Trim())); failureData++; continue; } try { SupplierPriceTable = new BaseSupplierPriceTable(); SupplierPriceTable.SUPPLIER_CODE = CConvert.ToString(GetValue(dr, "SUPPLIER_CODE")); SupplierPriceTable.PRODUCT_CODE = CConvert.ToString(GetValue(dr, "PRODUCT_CODE")); SupplierPriceTable.UNIT_CODE = CConvert.ToString(GetValue(dr, "UNIT_CODE")); SupplierPriceTable.CURRENCY_CODE = CConvert.ToString(GetValue(dr, "CURRENCY_CODE")); SupplierPriceTable.PRICE = CConvert.ToDecimal(GetValue(dr, "PRICE", 0)); SupplierPriceTable.STATUS_FLAG = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL)); SupplierPriceTable.CREATE_USER = _userInfo.CODE; SupplierPriceTable.LAST_UPDATE_USER = _userInfo.CODE; if (!bSupplierPrice.Exists(SupplierPriceTable.SUPPLIER_CODE, SupplierPriceTable.PRODUCT_CODE, SupplierPriceTable.UNIT_CODE, SupplierPriceTable.CURRENCY_CODE)) { bSupplierPrice.Add(SupplierPriceTable); } else { bSupplierPrice.Update(SupplierPriceTable); } 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 }); }