private void txtSupplierCode_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtSupplierCode.Text.Trim())) { BaseSupplierTable SupplierCode = new BaseSupplierTable(); BSupplier bSupplier = new BSupplier(); SupplierCode = bSupplier.GetModel(txtSupplierCode.Text); if (SupplierCode == null) { txtSupplierCode.Focus(); txtSupplierCode.Text = ""; txtSupplierName.Text = ""; MessageBox.Show("供应商编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { txtSupplierName.Text = SupplierCode.NAME; } } else { txtSupplierCode.Text = ""; txtSupplierName.Text = ""; } }
private void btnSupplier_Click(object sender, EventArgs e) { FrmMasterSearch frm = new FrmMasterSearch("SUPPLIER", ""); if (frm.ShowDialog(this) == DialogResult.OK) { if (frm.BaseMasterTable != null) { txtSupplierCode.Text = frm.BaseMasterTable.Code; txtSupplierName.Text = frm.BaseMasterTable.Name; BaseSupplierTable CurrenceCodeTable = GetSupplierCurrence(txtSupplierCode.Text.Trim()); if (CurrenceCodeTable != null) { //cboCurrency.SelectedValue = CurrenceCodeTable.CURRENCE_CODE; if (CurrenceCodeTable.TYPE == CConstant.ERP_DOMESTIC_NUMBER) { cboTax.SelectedValue = "01"; } else { cboTax.SelectedValue = "99"; } } txtWarehouseCode.Focus(); } } frm.Dispose(); }
private void txtSupplierCode_Leave(object sender, EventArgs e) { string SupplierCode = txtSupplierCode.Text.Trim(); if (!string.IsNullOrEmpty(SupplierCode)) { BaseMaster baseMaster = bCommon.GetBaseMaster("SUPPLIER", SupplierCode); BaseSupplierTable CurrenceCodeTable = GetSupplierCurrence(SupplierCode); if (baseMaster != null) { txtSupplierCode.Text = baseMaster.Code; txtSupplierName.Text = baseMaster.Name; } else { MessageBox.Show("供应商编号不存在.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSupplierCode.Text = ""; txtSupplierName.Text = ""; txtSupplierCode.Focus(); } } else { txtSupplierName.Text = ""; } }
protected BaseSupplierTable GetSupplierCurrence(string CODE) { BaseSupplierTable supplierTable = new BaseSupplierTable(); supplierTable = bSupplier.GetModel(CODE); return(supplierTable); }
private void txtClaimCode_Leave(object sender, EventArgs e) { BaseSupplierTable claim = new BaseSupplierTable(); claim = bSupplier.GetModel(txtClaimCode.Text); if (claim == null) { txtClaimCode.Text = ""; txtClaimCode.Focus(); MessageBox.Show("付款公司编号不存在!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// 保存 /// </summary> private void btnSave_Click_1(object sender, EventArgs e) { if (CheckInput()) { if (_currentSupplierTable == null) { _currentSupplierTable = new BaseSupplierTable(); } _currentSupplierTable.CODE = txtCode.Text.Trim(); _currentSupplierTable.NAME = txtName.Text.Trim(); _currentSupplierTable.NAME_SHORT = txtNameShort.Text.Trim(); _currentSupplierTable.NAME_ENGLISH = txtEnglishName.Text.Trim(); _currentSupplierTable.ZIP_CODE = txtZipCode.Text.Trim(); _currentSupplierTable.ADDRESS_FIRST = txtAddressFirst.Text.Trim(); _currentSupplierTable.ADDRESS_MIDDLE = txtAddressMiddle.Text.Trim(); //_currentSupplierTable.ADDRESS_LAST = txtAddressLast.Text; _currentSupplierTable.PHONE_NUMBER = txtPhone.Text.Trim(); _currentSupplierTable.FAX_NUMBER = txtFax.Text.Trim(); _currentSupplierTable.MOBIL_NUMBER = txtMobilNumber.Text.Trim(); _currentSupplierTable.CONTACT_NAME = txtContactName.Text.Trim(); _currentSupplierTable.EMAIL = txtEmail.Text.Trim(); _currentSupplierTable.URL = txtURL.Text.Trim(); _currentSupplierTable.MEMO = txtMemo.Text.Trim(); //_currentSupplierTable.CLAIM_CODE = txtClaimCode.Text; _currentSupplierTable.CURRENCE_CODE = CConstant.EXCHANGE_CHIAN; _currentSupplierTable.LAST_UPDATE_USER = _userInfo.CODE; _currentSupplierTable.PHONE_NUMBER_LAST = txtPhoneLast.Text.Trim(); _currentSupplierTable.FAX_NUMBER_LAST = txtFaxLast.Text.Trim(); try { if (bSupplier.Exists(txtCode.Text)) { bSupplier.Update(_currentSupplierTable); } else { _currentSupplierTable.CREATE_USER = _userInfo.CODE; bSupplier.Add(_currentSupplierTable); } } catch (Exception ex) { //log.error MessageBox.Show(""); return; } result = DialogResult.OK; this.Close(); } }
private void txtCode_Leave(object sender, EventArgs e) { //判断编号是否已存在 if (!string.IsNullOrEmpty(this.txtCode.Text.Trim())) { BaseSupplierTable SupplierCode = new BaseSupplierTable(); SupplierCode = bSupplier.GetModel(txtCode.Text); if (SupplierCode != 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 != "") { _currentSupplierTable = bSupplier.GetModel(code); } } catch (Exception ex) { } if (_currentSupplierTable == null || _currentSupplierTable.CODE == null || "".Equals(_currentSupplierTable.CODE)) { _currentSupplierTable = null; } }
/// <summary> /// 打开新窗口 /// </summary> private void OpenDialogFrm(int mode) { if (mode == CConstant.MODE_NEW || _currentSupplierTable != null) { FrmSupplierDialog frm = new FrmSupplierDialog(); frm.UserInfo = _userInfo; frm.CurrentSupplierTable = _currentSupplierTable; 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); } _currentSupplierTable = null; }
private void txtSupplierCode_Leave(object sender, EventArgs e) { string SupplierCode = txtSupplierCode.Text.Trim(); if (!string.IsNullOrEmpty(SupplierCode)) { BaseMaster baseMaster = bCommon.GetBaseMaster("SUPPLIER", SupplierCode); BaseSupplierTable CurrenceCodeTable = GetSupplierCurrence(SupplierCode); if (baseMaster != null) { txtSupplierCode.Text = baseMaster.Code; txtSupplierName.Text = baseMaster.Name; if (CurrenceCodeTable != null) { //cboCurrency.SelectedValue = CurrenceCodeTable.CURRENCE_CODE; if (CurrenceCodeTable.TYPE == CConstant.ERP_DOMESTIC_NUMBER) { cboTax.SelectedValue = "01"; } else { cboTax.SelectedValue = "99"; } } } else { MessageBox.Show("供应商编号不存在.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSupplierCode.Text = ""; txtSupplierName.Text = ""; txtSupplierCode.Focus(); } } else { txtSupplierName.Text = ""; } }
/// <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 (_currentSupplierTable != null) { bSupplier.Delete(_currentSupplierTable.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); } _currentSupplierTable = null; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BaseSupplierTable model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(BaseSupplierTable model) { return(dal.Add(model)); }
private void btnInquirySheet_Click(object sender, EventArgs e) { if (dgvData.SelectedRows.Count > 0) { Hashtable ht = new Hashtable(); DataTable dt = new DataTable(); DataGridViewRow row = dgvData.SelectedRows[0]; BllPurchaseOrderTable purchase = bPurchaseOrder.GetModel(CConvert.ToString(row.Cells["SLIP_NUMBER"].Value)); BaseSupplierTable supplier = bSupplier.GetModel(CConvert.ToString(row.Cells["SUPPLIER_CODE"].Value)); if (purchase == null) { purchase = new BllPurchaseOrderTable(); } if (supplier == null) { supplier = new BaseSupplierTable(); } ht.Add("&SUPPLIER", supplier.NAME); ht.Add("&CONTACT_NAME", supplier.CONTACT_NAME); ht.Add("&MOBIL_NUMBER", supplier.MOBIL_NUMBER); ht.Add("&PHONE_NUMBER", supplier.PHONE_NUMBER); ht.Add("&FAX_NUMBER", supplier.FAX_NUMBER); dt.Columns.Add("No"); dt.Columns.Add("SPEC"); dt.Columns.Add("NAME"); dt.Columns.Add("UNIT_NAME"); dt.Columns.Add("QUANTITY"); dt.Columns.Add("PRICE"); dt.Columns.Add("TOTAL_AMOUNT"); dt.Columns.Add("APPLICATION"); dt.Columns.Add("MEMO"); DataRow rows = null; int i = 0; string name = ""; decimal TOTAL = 0; foreach (BllPurchaseOrderLineTable POLTable in purchase.Items) { rows = dt.NewRow(); rows["No"] = POLTable.LINE_NUMBER; BaseProductTable product = bProduct.GetModel(POLTable.PRODUCT_CODE); if (product != null) { rows["SPEC"] = product.CODE; rows["NAME"] = product.NAME; if (i == 0) { name = product.NAME; } if (bCommon.GetBaseMaster("UNIT", POLTable.UNIT_CODE) != null) { rows["UNIT_NAME"] = bCommon.GetBaseMaster("UNIT", POLTable.UNIT_CODE).Name; } } rows["QUANTITY"] = (int)POLTable.QUANTITY; rows["PRICE"] = POLTable.PRICE; rows["TOTAL_AMOUNT"] = POLTable.AMOUNT_INCLUDED_TAX; rows["MEMO"] = purchase.MEMO; dt.Rows.Add(rows); TOTAL += POLTable.AMOUNT_INCLUDED_TAX; i++; } ht.Add("&TOTAL", TOTAL); SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "HD_INQUIRY_" + supplier.NAME + "_" + purchase.SLIP_DATE.ToString("yyyyMMdd") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; if (sf.ShowDialog(this) == DialogResult.OK) { if (dt.Rows.Count > 0) { int ret = CExport.DataTableToExcel_IS(@"rpt\HD_INQUIRY.xls", sf.FileName, dt, ht); if (CConstant.EXPORT_FAILURE.Equals(ret)) { MessageBox.Show("导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_SUCCESS.Equals(ret)) { MessageBox.Show("导出成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (CConstant.EXPORT_RUNNING.Equals(ret)) { MessageBox.Show("文件正在运行,重新生成文件失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (CConstant.EXPORT_TEMPLETE_FILE_NOT_EXIST.Equals(ret)) { MessageBox.Show("模版文件不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("明细信息不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } }
public override string[] doUpdateDB() { BaseSupplierTable SupplierTable = null; BSupplier bSupplier = new BSupplier(); 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(CheckLenght(GetValue(dr, "NAME_SHORT"), 50, "简称")); //英文名称 str.Append(CheckLenght(GetValue(dr, "NAME_ENGLISH"), 50, "英文名称")); //邮编 str.Append(CheckLenght(GetValue(dr, "ZIP_CODE"), 8, "邮编")); //地址1 str.Append(CheckLenght(GetValue(dr, "ADDRESS_FIRST"), 100, "地址1")); //地址2 str.Append(CheckLenght(GetValue(dr, "ADDRESS_MIDDLE"), 100, "地址2")); //地址3 str.Append(CheckLenght(GetValue(dr, "ADDRESS_LAST"), 100, "地址3")); //电话 str.Append(CheckLenght(GetValue(dr, "PHONE_NUMBER"), 20, "电话")); //传真 str.Append(CheckLenght(GetValue(dr, "FAX_NUMBER"), 20, "传真")); //联系人名称 str.Append(CheckLenght(GetValue(dr, "CONTACT_NAME"), 50, "联系人名称")); //联系人电话 str.Append(CheckLenght(GetValue(dr, "MOBIL_NUMBER"), 20, "联系人电话")); //邮箱 str.Append(CheckLenght(GetValue(dr, "EMIAL"), 50, "邮箱")); //网址 str.Append(CheckLenght(GetValue(dr, "URL"), 50, "网址")); //备注 str.Append(CheckLenght(GetValue(dr, "MEMO"), 255, "备注")); //类型 if (CConvert.ToInt32(GetValue(dr, "TYPE", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "TYPE", 1)) != 2 && CConvert.ToString(GetValue(dr, "TYPE", 1)) != "") { str.Append("类型只能为1或2!"); } //是否请款公司 if (CConvert.ToInt32(GetValue(dr, "CLAIM_FLAG", 1)) != 1 && CConvert.ToInt32(GetValue(dr, "CLAIM_FLAG", 1)) != 2 && CConvert.ToString(GetValue(dr, "CLAIM_FLAG", 1)) != "") { str.Append("是否付款公司只能为1或2!"); } else { str.Append(CheckInt(GetValue(dr, "CLAIM_FLAG", 1), 2, "是否付款公司")); } //请款公司编号 str.Append(CheckLenght(GetValue(dr, "CLAIM_CODE"), 20, "付款供应商编号")); //货币 if (!string.IsNullOrEmpty(CConvert.ToString(GetValue(dr, "CURRENCE_CODE")))) { str.Append(CheckCurrency(CConvert.ToString(GetValue(dr, "CURRENCE_CODE")), "货币")); } //状态 str.Append(CheckInt(GetValue(dr, "STATUS_FLAG", 1), 9, "状态")); if (str.ToString().Trim().Length > 0) { strError.Append(GetStringBuilder(dr, str.ToString().Trim())); failureData++; continue; } try { SupplierTable = new BaseSupplierTable(); SupplierTable.CODE = CConvert.ToString(GetValue(dr, "CODE")); SupplierTable.NAME = CConvert.ToString(GetValue(dr, "NAME")); SupplierTable.NAME_SHORT = CConvert.ToString(GetValue(dr, "NAME_SHORT")); SupplierTable.NAME_ENGLISH = CConvert.ToString(GetValue(dr, "NAME_ENGLISH")); SupplierTable.ZIP_CODE = CConvert.ToString(GetValue(dr, "ZIP_CODE")); SupplierTable.ADDRESS_FIRST = CConvert.ToString(GetValue(dr, "ADDRESS_FIRST")); SupplierTable.ADDRESS_MIDDLE = CConvert.ToString(GetValue(dr, "ADDRESS_MIDDLE")); SupplierTable.ADDRESS_LAST = CConvert.ToString(GetValue(dr, "ADDRESS_LAST")); SupplierTable.PHONE_NUMBER = CConvert.ToString(GetValue(dr, "PHONE_NUMBER")); SupplierTable.FAX_NUMBER = CConvert.ToString(GetValue(dr, "FAX_NUMBER")); SupplierTable.CONTACT_NAME = CConvert.ToString(GetValue(dr, "CONTACT_NAME")); SupplierTable.MOBIL_NUMBER = CConvert.ToString(GetValue(dr, "MOBIL_NUMBER")); SupplierTable.EMAIL = CConvert.ToString(GetValue(dr, "EMIAL")); SupplierTable.URL = CConvert.ToString(GetValue(dr, "URL")); SupplierTable.MEMO = CConvert.ToString(GetValue(dr, "MEMO")); SupplierTable.TYPE = CConvert.ToInt32(GetValue(dr, "TYPE", 1)); SupplierTable.CLAIM_FLAG = CConvert.ToInt32(GetValue(dr, "CLAIM_FLAG", 1)); SupplierTable.CLAIM_CODE = CConvert.ToString(GetValue(dr, "CLAIM_CODE")); SupplierTable.CURRENCE_CODE = CConvert.ToString(GetValue(dr, "CURRENCE_CODE")); SupplierTable.STATUS_FLAG = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", 1)); SupplierTable.CREATE_USER = _userInfo.CODE; SupplierTable.LAST_UPDATE_USER = _userInfo.CODE; if (!bSupplier.Exists(SupplierTable.CODE)) { SupplierTable.CREATE_DATE_TIME = DateTime.Now; SupplierTable.LAST_UPDATE_TIME = DateTime.Now; bSupplier.Add(SupplierTable); } else { SupplierTable.LAST_UPDATE_TIME = DateTime.Now; bSupplier.Update(SupplierTable); } 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 }); }