private bool ExportVendorAVMX(MasterData.VendorRow vendor, int logId) { string BakPath = ConfigurationManager.AppSettings["ExportService.BakPath"]; try { string FileName = ConfigurationManager.AppSettings["ExportService.VendorAVMXFileName"]; string spit = "\t"; MasterDataBLL masterdatabll = new MasterDataBLL(); MasterData.CurrencyRow currency = null; MasterData.VendorTypeRow vendorType = null; MasterData.TransTypeRow transType = null; MasterData.BankCodeRow bankCode = null; MasterData.ACTypeRow acType = null; vendorType = masterdatabll.GetVendorTypeById(vendor.VendorTypeID); currency = masterdatabll.GetCurrencyByID(vendorType.CurrencyID); if (!vendor.IsBankCodeIDNull()) { MasterData.BankCodeDataTable tbBankCode = masterdatabll.GetBankCodeById(vendor.BankCodeID); bankCode = tbBankCode[0]; if (bankCode.BankCode.Equals("999")) { throw new Exception("BankCode为999不导出!"); } } if (!vendor.IsTransTypeIDNull()) { MasterData.TransTypeDataTable tbTransType = masterdatabll.GetTransTypeById(vendor.TransTypeID); transType = tbTransType[0]; } if (!vendor.IsACTypeIDNull()) { MasterData.ACTypeDataTable tbACType = masterdatabll.GetACTypeById(vendor.ACTypeID); acType = masterdatabll.GetACTypeById(vendor.ACTypeID)[0]; } if (vendor.IsAccountNoNull()) { throw new Exception("银行账号为空的不导出!"); } string content = (vendor.IsActive ? "VM" : "VZ") + spit + bSubstring(vendor.VendorCode, 5) + spit + bSubstring(currency.CurrencyShortName, 3) + spit + bSubstring(bankCode.BankCode, 3) + spit + bSubstring(transType == null ? "" : transType.TransTypeName, 2) + spit + bSubstring(vendor.IsBankNameNull() ? "" : vendor.BankName, 68) + spit + bSubstring(vendor.IsAccountNoNull() ? "" : vendor.AccountNo, 32) + spit + bSubstring(vendor.VendorName, 58) + spit + bSubstring(acType == null ? "" : acType.ACTypeName, 1) + spit + 0 + spit + bSubstring(vendor.IsBankNoNull() ? "" : vendor.BankNo, 11); content = content.Replace("\r", "").Replace("\n", "") + "\r\n"; File.AppendAllText(path + FileName, content, Encoding.Default); File.AppendAllText(BakPath + DateTime.Now.ToString("yyyyMMddhhmmss") + FileName, content, Encoding.Default); } catch (Exception e) { logbll.InsertExportLogDetail(logId, "VendorCode:" + vendor.VendorCode + ",VendorName:" + vendor.VendorName + "" + ",错误信息:" + e.Message); return false; } return true; }