private void txtDepartualCode_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtDepartualCode.Text.Trim())) { BaseWarehouseTable Warehouse = new BaseWarehouseTable(); BWarehouse bWarehouse = new BWarehouse(); Warehouse = bWarehouse.GetModel(this.txtDepartualCode.Text); if (Warehouse == null || "".Equals(Warehouse)) { txtDepartualCode.Focus(); txtDepartualCode.Text = ""; txtDepartualName.Text = ""; MessageBox.Show("仓库编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { txtDepartualCode.Text = Warehouse.CODE; txtDepartualName.Text = Warehouse.NAME; } } else { txtDepartualName.Text = ""; } }
private void txtWarehouseCode_Leave(object sender, EventArgs e) { //判断编号是否已存在 if (!string.IsNullOrEmpty(this.txtWarehouseCode.Text.Trim()) && !string.IsNullOrEmpty(this.txtProductCode.Text.Trim())) { BaseSafetyStockTable SafetyCode = new BaseSafetyStockTable(); SafetyCode = bSafetyStock.GetModel(txtWarehouseCode.Text, txtProductCode.Text); if (SafetyCode != null) { txtWarehouseCode.Text = ""; txtWarehouseName.Text = ""; txtProductCode.Text = ""; txtProductName.Text = ""; txtWarehouseCode.Focus(); MessageBox.Show("仓库编号与商品编号的组合已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } if (!string.IsNullOrEmpty(this.txtWarehouseCode.Text.Trim())) { BaseWarehouseTable Warehouse = new BaseWarehouseTable(); BWarehouse bWarehouse = new BWarehouse(); Warehouse = bWarehouse.GetModel(this.txtWarehouseCode.Text); if (Warehouse == null || "".Equals(Warehouse)) { txtWarehouseCode.Focus(); txtWarehouseCode.Text = ""; txtWarehouseName.Text = ""; MessageBox.Show("仓库编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { txtWarehouseName.Text = Warehouse.NAME; } } }
protected string CheckWarehouse(string warehouseCode, string title) { if (warehouseCode == null || "".Equals(warehouseCode.ToString())) { return(title + ERROR_NULL); } if (_wasehouseTable[warehouseCode] != null) { return(""); } BWarehouse bWarehouse = new BWarehouse(); if (bWarehouse.Exists(warehouseCode)) { _wasehouseTable.Add(warehouseCode, warehouseCode); return(""); } return(title + ERROR_EXIST); }
public override string[] doUpdateDB() { BaseWarehouseTable WarehouseTable = null; BWarehouse bWarehouse = new BWarehouse(); 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, "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, "MEMO"), 255, "备注")); //状态 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 { WarehouseTable = new BaseWarehouseTable(); WarehouseTable.CODE = CConvert.ToString(GetValue(dr, "CODE")); WarehouseTable.NAME = CConvert.ToString(GetValue(dr, "NAME")); WarehouseTable.NAME_SHORT = CConvert.ToString(GetValue(dr, "NAME_SHORT")); WarehouseTable.ZIP_CODE = CConvert.ToString(GetValue(dr, "ZIP_CODE")); WarehouseTable.ADDRESS_FIRST = CConvert.ToString(GetValue(dr, "ADDRESS_FIRST")); WarehouseTable.ADDRESS_MIDDLE = CConvert.ToString(GetValue(dr, "ADDRESS_MIDDLE")); WarehouseTable.ADDRESS_LAST = CConvert.ToString(GetValue(dr, "ADDRESS_LAST")); WarehouseTable.PHONE_NUMBER = CConvert.ToString(GetValue(dr, "PHONE_NUMBER")); WarehouseTable.FAX_NUMBER = CConvert.ToString(GetValue(dr, "FAX_NUMBER")); WarehouseTable.CONTACT_NAME = CConvert.ToString(GetValue(dr, "CONTACT_NAME")); WarehouseTable.MOBIL_NUMBER = CConvert.ToString(GetValue(dr, "MOBIL_NUMBER")); WarehouseTable.EMAIL = CConvert.ToString(GetValue(dr, "EMIAL")); WarehouseTable.MEMO = CConvert.ToString(GetValue(dr, "MEMO")); WarehouseTable.STATUS_FLAG = CConvert.ToInt32(GetValue(dr, "STATUS_FLAG", CConstant.NORMAL_STATUS)); WarehouseTable.CREATE_USER = _userInfo.CODE; WarehouseTable.LAST_UPDATE_USER = _userInfo.CODE; if (!bWarehouse.Exists(WarehouseTable.CODE)) { WarehouseTable.CREATE_DATE_TIME = DateTime.Now; WarehouseTable.LAST_UPDATE_TIME = DateTime.Now; bWarehouse.Add(WarehouseTable); } else { WarehouseTable.LAST_UPDATE_TIME = DateTime.Now; bWarehouse.Update(WarehouseTable); } 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 }); }
private void btnPurcahse_Click(object sender, EventArgs e) { if (dgvData.SelectedRows.Count > 0) { Hashtable ht = null; DataTable dt = null; DataGridViewRow row = dgvData.SelectedRows[0]; BaseCompanyTable company = new BCompany().GetModel(_userInfo.COMPANY_CODE); BllPurchaseOrderTable purchase = bPurchaseOrder.GetModel(CConvert.ToString(row.Cells["SLIP_NUMBER"].Value)); BllOrderHeaderTable order = new BOrderHeader().GetModel(purchase.ORDER_SLIP_NUMBER); BaseWarehouseTable warehouse = new BWarehouse().GetModel(purchase.RECEIPT_WAREHOUSE_CODE); if (company == null) { company = new BaseCompanyTable(); } if (warehouse == null) { warehouse = new BaseWarehouseTable(); } if (purchase == null) { purchase = new BllPurchaseOrderTable(); } BaseSupplierTable supplier = new BSupplier().GetModel(purchase.SUPPLIER_CODE); if (supplier.TYPE == 2) { #region 国内 ht = new Hashtable(); ht.Add("&COMPANY_NAME", company.NAME); ht.Add("&ADDRESS", company.ADDRESS_FIRST + company.ADDRESS_MIDDLE + company.ADDRESS_LAST); if (string.IsNullOrEmpty(company.PHONE_NUMBER.ToString())) { ht.Add("&PHONE", "TEL " + "FAX" + company.FAX_NUMBER); } else { ht.Add("&PHONE", "TEL" + company.PHONE_NUMBER.ToString() + "FAX" + company.FAX_NUMBER); } ht.Add("&SLIP_NUMBER", purchase.SLIP_NUMBER); ht.Add("&SLIP_DATE", purchase.SLIP_DATE.ToString("yyyy年MM月dd日")); ht.Add("&SUPPLIER", "厂商名称:" + supplier.NAME); // ht.Add("&NAME", company.NAME); ht.Add("&DUE_DATE", "1.交货日期:" + CConvert.ToDateTime(purchase.DUE_DATE).ToShortDateString()); ht.Add("&PACKING_METHOD", "2.包装方式:" + purchase.PACKING_METHOD); ht.Add("&WAREHOUSE_NAME", "3.交货地址:" + warehouse.ADDRESS_FIRST + warehouse.ADDRESS_MIDDLE + warehouse.ADDRESS_LAST); ht.Add("&PAYMENT_CONDITION", "4.支付方式:" + purchase.PAYMENT_CONDITION); dt = new DataTable(); dt.Columns.Add("NO"); dt.Columns.Add("MODEL_NUMBER"); dt.Columns.Add("PRODUCT_NAME"); dt.Columns.Add("SPEC"); dt.Columns.Add("QUANTITY"); dt.Columns.Add("PRICE"); dt.Columns.Add("AMOUNT_WITHOUT_TAX"); //dt.Columns.Add("AMOUNT_INCLUDED_TAX"); dt.Columns.Add("DUE_DATE"); decimal amount = 0; decimal taxAmount = 0; DataRow rows = null; foreach (BllPurchaseOrderLineTable OLModel in purchase.Items) { rows = dt.NewRow(); rows["NO"] = OLModel.LINE_NUMBER; if (OLModel.PRODUCT_CODE.Length >= 4 && OLModel.PRODUCT_CODE.Substring(0, 4) == "9999") { rows["PRODUCT_NAME"] = OLModel.PRODUCT_NAME; rows["SPEC"] = OLModel.PRODUCT_SPEC; rows["MODEL_NUMBER"] = ""; } else { BaseProductTable product = new BProduct().GetModel(OLModel.PRODUCT_CODE); if (product != null) { rows["PRODUCT_NAME"] = product.NAME; rows["SPEC"] = product.SPEC; rows["MODEL_NUMBER"] = product.MODEL_NUMBER; } } rows["QUANTITY"] = OLModel.QUANTITY; rows["PRICE"] = OLModel.PRICE; rows["AMOUNT_WITHOUT_TAX"] = Convert.ToDouble(CConvert.ToDecimal(rows["QUANTITY"]) * CConvert.ToDecimal(rows["PRICE"])).ToString("0.00"); //rows["AMOUNT_INCLUDED_TAX"] = OLModel.AMOUNT_INCLUDED_TAX; rows["DUE_DATE"] = CConvert.ToDateTime(purchase.DUE_DATE).ToString("yyyy/MM/dd"); amount += OLModel.AMOUNT_WITHOUT_TAX; taxAmount += OLModel.TAX_AMOUNT; dt.Rows.Add(rows); } ht.Add("&AMOUNT", amount); ht.Add("&TAX_AMOUNT", taxAmount); ht.Add("&TOTAL_AMOUNT", amount + taxAmount); SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_PURCHASE_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; if (sf.ShowDialog(this) == DialogResult.OK) { if (dt.Rows.Count > 0) { int ret = CommonExport.ExportPurchase(@"rpt\purchase.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); } } #endregion } else { decimal AMOUNT_WITHOUT_TAX = 0; decimal ORDER_AMOUNT = 0; #region 国外 ht = new Hashtable(); ht.Add("&SUPPLIER_NAME", supplier.NAME); ht.Add("&CONTACT_NAME", supplier.CONTACT_NAME); ht.Add("&PHONE", supplier.PHONE_NUMBER); ht.Add("&FAX", supplier.FAX_NUMBER); // ht.Add("&ORDER_NUMBER", purchase.ORDER_SLIP_NUMBER); ht.Add("&SLIP_NUMBER", purchase.SLIP_NUMBER); ht.Add("&SUPPLIER_ORDER_CODE", purchase.SUPPLIER_ORDER_NUMBER); ht.Add("&PURCHASE_QUOTATION_NUMBER", purchase.PURCHASE_QUOTATION_NUMBER); if (order != null) { ht.Add("&CUSTOMER_PO_NUMBER", order.CUSTOMER_PO_NUMBER); string customerCode = ""; //if (!string.IsNullOrEmpty(order.CUSTOMER_NAME)) //{ // customerCode = order.CUSTOMER_CODE; // ht.Add("&CUSTOMER_NAME", order.CUSTOMER_NAME); //} //else //{ customerCode = order.ENDER_CUSTOMER_CODE; ht.Add("&CUSTOMER_NAME", order.ENDER_CUSTOMER_NAME); //} ht.Add("&DELIVERY_DATE", order.DUE_DATE); ht.Add("&SERIAL_NUMBER", order.SERIAL_NUMBER); ht.Add("&AIRCRAFT", order.SERIAL_TYPE); BaseCustomerTable customer = new BCustomer().GetModel(customerCode); ht.Add("&CUSTOMER_CONTACT_NAME", customer.CONTACT_NAME); ht.Add("&CUSTOMER_PHONE", customer.PHONE_NUMBER); //ht.Add("&ORDER_AMOUNT", order.AMOUNT_INCLUDED_TAX); } else { ht.Add("&CUSTOMER_PO_NUMBER", ""); ht.Add("&DELIVERY_DATE", ""); ht.Add("&SERIAL_NUMBER", ""); //ht.Add("&ORDER_AMOUNT", ""); ht.Add("&AIRCRAFT", ""); ht.Add("&CUSTOMER_NAME", company.NAME_SHORT); ht.Add("&CUSTOMER_CONTACT_NAME", ""); ht.Add("&CUSTOMER_PHONE", company.PHONE_NUMBER); } ht.Add("&MEMO", purchase.MEMO); ht.Add("&TOTAL_AMOUNT", purchase.TOTAL_AMOUNT); ht.Add("&PAYMENT", purchase.PAYMENT_CONDITION); ht.Add("&SLIP_DATE", purchase.SLIP_DATE); ht.Add("&DUE_DATE", purchase.DUE_DATE); dt = new DataTable(); dt.Columns.Add("NO"); dt.Columns.Add("PRODUCT_CODE"); dt.Columns.Add("X_1", Type.GetType("System.String")); dt.Columns.Add("PRODUCT_NAME"); dt.Columns.Add("X_2", Type.GetType("System.String")); dt.Columns.Add("MODEL_NUMBER"); dt.Columns.Add("X_3", Type.GetType("System.String")); dt.Columns.Add("QUANTITY"); dt.Columns.Add("PRICE"); dt.Columns.Add("AMOUNT_WITHOUT_TAX"); DataRow rows = null; foreach (BllPurchaseOrderLineTable OLModel in purchase.Items) { AMOUNT_WITHOUT_TAX += OLModel.AMOUNT_INCLUDED_TAX; if (order != null) { foreach (BllOrderLineTable line in order.Items) { if (line.PRODUCT_CODE == OLModel.PRODUCT_CODE) { ORDER_AMOUNT += CConvert.ToDecimal(line.AMOUNT); break; } } } else { ORDER_AMOUNT += 0; } rows = dt.NewRow(); rows["NO"] = OLModel.LINE_NUMBER; rows["PRODUCT_CODE"] = OLModel.PRODUCT_CODE; if (OLModel.PRODUCT_CODE.Length >= 4 && OLModel.PRODUCT_CODE.Substring(0, 4) == "9999") { rows["PRODUCT_NAME"] = OLModel.PRODUCT_NAME; rows["MODEL_NUMBER"] = OLModel.PRODUCT_SPEC; } else { BaseProductTable product = new BProduct().GetModel(OLModel.PRODUCT_CODE); if (product != null) { if (!string.IsNullOrEmpty(product.NAME_JP)) { rows["PRODUCT_NAME"] = product.NAME_JP; } else { rows["PRODUCT_NAME"] = product.NAME; } rows["MODEL_NUMBER"] = product.SPEC + " " + product.MODEL_NUMBER; } } rows["QUANTITY"] = OLModel.QUANTITY; rows["PRICE"] = OLModel.PRICE; rows["AMOUNT_WITHOUT_TAX"] = OLModel.AMOUNT_INCLUDED_TAX; dt.Rows.Add(rows); } ht.Add("&AMOUNT_WITHOUT_TAX", AMOUNT_WITHOUT_TAX); ht.Add("&ORDER_AMOUNT", ORDER_AMOUNT); SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "LZ_PURCHASE_OVERSEAS_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; sf.Filter = "(文件)|*.xls;*.xlsx"; if (sf.ShowDialog(this) == DialogResult.OK) { if (dt.Rows.Count > 0) { int ret = CommonExport.ExportPurchaseOverseas(@"rpt\purchase_overseas.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); } } #endregion } } else { MessageBox.Show("请选择一行!"); } }