public void UpdateVendor(int FormVendorID) { PurchaseDS.FormVendorRow FormVendorRow = new FormVendorBLL().GetFormVendorByID(FormVendorID)[0]; MasterData.VendorRow VendorRow = this.TAVendor.GetDataByID(FormVendorRow.VendorID)[0]; MasterData.VendorTypeRow vendorTypeRow = new MasterDataBLL().GetVendorTypeById(FormVendorRow.VendorTypeID); VendorRow.VendorName = FormVendorRow.VendorName; VendorRow.VendorAddress = FormVendorRow.VendorAddress; VendorRow.City = FormVendorRow.City; VendorRow.Postal = FormVendorRow.Postal; VendorRow.ContactName = FormVendorRow.ContactName; VendorRow.VendorTypeID = FormVendorRow.VendorTypeID; VendorRow.CompanyID = vendorTypeRow.CompanyID; VendorRow.PhoneNumber = FormVendorRow.PhoneNumber; VendorRow.OneTimeVendor = FormVendorRow.OneTimeVendor; VendorRow.HoldVendor = FormVendorRow.HoldVendor; VendorRow.PurchaseingPostalCode = FormVendorRow.PurchaseingPostalCode; VendorRow.AlphaSearchKey = FormVendorRow.AlphaSearchKey; VendorRow.PurchasingContact = FormVendorRow.PurchasingContact; VendorRow.PurchasingAddress = FormVendorRow.PurchasingAddress; VendorRow.PurchasingCity = FormVendorRow.PurchasingCity; VendorRow.PurchasePhoneNumber = FormVendorRow.PurchasePhoneNumber; VendorRow.BankCode = FormVendorRow.BankCode; VendorRow.MethodPaymentID = FormVendorRow.MethodPaymentID; VendorRow.PaymentTermID = FormVendorRow.PaymentTermID; VendorRow.TransTypeID = FormVendorRow.TransTypeID; VendorRow.VATTypeID = FormVendorRow.VATTypeID; VendorRow.BankName = FormVendorRow.BankName; VendorRow.AccountNo = FormVendorRow.AccountNo; VendorRow.BankNo = FormVendorRow.BankNo; VendorRow.ACTypeID = FormVendorRow.ACTypeID; if (!FormVendorRow.IsRemarkNull()) { VendorRow.Remark = FormVendorRow.Remark; } VendorRow.BankCodeID = FormVendorRow.BankCodeID; if (FormVendorRow.ActionType == (int)SystemEnums.VendorActionType.Delete) { VendorRow.IsActive = false; } if (FormVendorRow.ActionType == (int)SystemEnums.VendorActionType.Reactive) { VendorRow.IsActive = true; } VendorRow.ActionType = FormVendorRow.ActionType; VendorRow.IsExport = false; this.TAVendor.Update(VendorRow); FormVendorRow.VendorID = VendorRow.VendorID; new PurchaseDSTableAdapters.FormVendorTableAdapter().Update(FormVendorRow); }
/// <summary> /// Vendor导出 /// </summary> /// <param name="FormID"></param> /// <returns></returns> private bool ExportVendorAVM(MasterData.VendorRow vendor, int logId) { string BakPath = ConfigurationManager.AppSettings["ExportService.BakPath"]; FormVendorBLL formvendorbll = new FormVendorBLL(); MasterDataBLL masterdatabll = new MasterDataBLL(); try { string FileName = ConfigurationManager.AppSettings["ExportService.VendorAVMFileName"]; string spit = "\t"; MasterData.PaymentTermRow paymentTerm = null; MasterData.VendorTypeRow vendorType = null; MasterData.CompanyRow company = null; MasterData.CurrencyRow currency = null; MasterData.MethodPaymentRow paymentType = null; MasterData.VatTypeRow VatType = null; MasterData.BankCodeRow bankCode = null; MasterData.TransTypeRow transType = null; MasterData.ACTypeRow acType = null; paymentTerm = masterdatabll.GetPaymentTermById(vendor.PaymentTermID)[0]; vendorType = masterdatabll.GetVendorTypeById(vendor.VendorTypeID); company = masterdatabll.GetCompanyById(vendor.CompanyID); currency = masterdatabll.GetCurrencyByID(vendorType.CurrencyID); paymentType = masterdatabll.GetMethodPaymentById(vendor.MethodPaymentID)[0]; VatType = masterdatabll.GetVatTypeById(vendor.VATTypeID)[0]; bankCode = masterdatabll.GetBankCodeById(vendor.BankCodeID)[0]; transType = masterdatabll.GetTransTypeById(vendor.TransTypeID)[0]; acType = masterdatabll.GetACTypeById(vendor.ACTypeID)[0]; string ActionName = ""; string content = ""; switch (vendor.ActionType) { case 0: ActionName = "D"; #region 删除 content = "" + spit + ActionName + spit + "" + spit + "VZ" + spit + bSubstring(vendor.VendorCode, 5) + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + 0 + spit + 0 + spit + 0 + spit + "" + spit + "" + spit + "" + spit + "" + spit + 0 + spit + "" + spit + "" + spit + "" + spit + 0 + spit + "" + spit + 0 + spit + 0 + spit + 0 + spit + 0 + spit + 0 + spit + 0 + spit + "" + spit + "" + spit + 0 + spit + "" + spit + "" + spit + 0 + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + 0 + spit + 0 + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + 0 + spit + 0 + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + "\r\n"; #endregion break; case 1: ActionName = "A"; #region 新增 content = "" + spit + ActionName + spit + (vendor.IsActive ? "A" : "D") + spit + (vendor.IsActive ? "VM" : "VZ") + spit + bSubstring(vendor.VendorCode, 5) + spit + bSubstring(vendor.VendorName, 28) + spit + bSubstring(vendor.VendorAddress, 28) + spit + SpitVendorAddress(vendor.VendorAddress) + spit + bSubstring(vendor.City, 17) + spit + "" + spit + bSubstring(vendor.Postal, 9) + spit + bSubstring(paymentTerm.PaymentTermName, 2) + spit + bSubstring(vendorType.VendorTypeName, 4) + spit + bSubstring(vendor.VendorCode, 5) + spit + 0 + spit + 0 + spit + "" + spit + "N" + spit + "" + spit + bSubstring(vendor.PhoneNumber, 15) + spit + bSubstring(company.CompanyCode, 2) + spit + bSubstring(currency.CurrencyShortName, 3) + spit + bSubstring(paymentType.MethodPaymentName, 1) + spit + (vendor.OneTimeVendor ? "Y" : "N") + spit + 0 + spit + (vendor.HoldVendor ? "Y" : "N") + spit + 0 + spit + 0 + spit + 0 + spit + 0 + spit + 0 + spit + 0 + spit + "N" + spit + bSubstring(vendor.AlphaSearchKey, 10) + spit + 0 + spit + bSubstring(vendor.ContactName, 30) + spit + "" + spit + 0 + spit + bSubstring(vendor.PurchasingAddress, 28) + spit + SpitVendorAddress(vendor.PurchasingAddress) + spit + bSubstring(vendor.PurchasingCity, 28) + spit + "" + spit + bSubstring(vendor.PurchaseingPostalCode, 9) + spit + bSubstring(vendor.PurchasingContact, 30) + spit + "" + spit + 0 + spit + 0 + spit + "N" + spit + bSubstring(vendor.PurchasePhoneNumber, 15) + spit + "" + spit + "" + spit + bSubstring(VatType.VatTypeName, 5) + spit + "" + spit + "" + spit + 0 + spit + 0 + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + 0 + "\r\n"; #endregion break; case 2: ActionName = "U"; #region 修改 QueryDS.FormVendorViewDataTable l_dtformvendor = formvendorbll.GetApproveFormVendorByVendorID(vendor.VendorID); if (l_dtformvendor.Rows.Count > 1) { QueryDS.FormVendorViewRow l_drformvendor = l_dtformvendor[1]; content = "" + spit + ActionName + spit + "" + spit + (vendor.IsActive ? "VM" : "VZ") + spit + bSubstring(vendor.VendorCode, 5) + spit + (bSubstring(vendor.VendorName, 28) == bSubstring(l_drformvendor.VendorName, 28) ? "" : bSubstring(vendor.VendorName, 28)) + spit + (bSubstring(vendor.VendorAddress, 28) == bSubstring(l_drformvendor.VendorAddress, 28) ? "" : vendor.VendorAddress) + spit + (SpitVendorAddress(vendor.VendorAddress) == SpitVendorAddress(l_drformvendor.VendorAddress) ? "" : SpitVendorAddress(vendor.VendorAddress)) + spit + (bSubstring(vendor.City, 17) == bSubstring(l_drformvendor.City, 17) ? "" : bSubstring(vendor.City, 17)) + spit + "" + spit + (bSubstring(vendor.Postal, 9) == bSubstring(l_drformvendor.Postal, 9) ? "" : bSubstring(vendor.Postal, 9)) + spit + bSubstring(l_drformvendor.MethodPaymentID == vendor.MethodPaymentID ? "" : paymentTerm.PaymentTermName, 2) + spit + bSubstring(vendor.VendorTypeID == l_drformvendor.VendorTypeID ? "" : vendorType.VendorTypeName, 4) + spit + 0 + spit + 0 + spit + 0 + spit + "" + spit + "" + spit + "" + spit + (bSubstring(vendor.PhoneNumber, 15) == bSubstring(l_drformvendor.PhoneNumber, 15) ? "" : bSubstring(vendor.PhoneNumber, 15)) + spit + (bSubstring(company.CompanyCode, 2) == bSubstring(l_drformvendor.CompanyCode, 2) ? "0" : bSubstring(company.CompanyCode, 2)) + spit + (bSubstring(currency.CurrencyShortName, 3) == bSubstring(l_drformvendor.CurrencyShortName, 3) ? "" : bSubstring(currency.CurrencyShortName, 3)) + spit + bSubstring(l_drformvendor.MethodPaymentID == vendor.MethodPaymentID ? "" : paymentType.MethodPaymentName, 1) + spit + (vendor.OneTimeVendor == l_drformvendor.OneTimeVendor ? "" : (vendor.OneTimeVendor ? "Y" : "N")) + spit + 0 + spit + (vendor.HoldVendor == l_drformvendor.HoldVendor ? "" : (vendor.HoldVendor ? "Y" : "N")) + spit + 0 + spit + 0 + spit + 0 + spit + 0 + spit + 0 + spit + 0 + spit + "" + spit + (bSubstring(vendor.AlphaSearchKey, 10) == bSubstring(l_drformvendor.AlphaSearchKey, 10) ? "" : bSubstring(vendor.AlphaSearchKey, 10)) + spit + 0 + spit + (bSubstring(vendor.ContactName, 30) == bSubstring(l_drformvendor.ContactName, 30) ? "" : bSubstring(vendor.ContactName, 30)) + spit + "" + spit + 0 + spit + (bSubstring(vendor.PurchasingAddress, 28) == bSubstring(l_drformvendor.PurchasingAddress, 28) ? "" : bSubstring(vendor.PurchasingAddress, 28)) + spit + (SpitVendorAddress(vendor.PurchasingAddress) == SpitVendorAddress(l_drformvendor.PurchasingAddress) ? "" : SpitVendorAddress(vendor.PurchasingAddress)) + spit + (bSubstring(vendor.PurchasingCity, 28) == bSubstring(l_drformvendor.PurchasingCity, 28) ? "" : bSubstring(vendor.PurchasingCity, 28)) + spit + "" + spit + (bSubstring(vendor.PurchaseingPostalCode, 9) == bSubstring(l_drformvendor.PurchaseingPostalCode, 9) ? "" : bSubstring(vendor.PurchaseingPostalCode, 9)) + spit + (bSubstring(vendor.PurchasingContact, 30) == bSubstring(l_drformvendor.PurchasingContact, 30) ? "" : bSubstring(vendor.PurchasingContact, 30)) + spit + "" + spit + 0 + spit + 0 + spit + "" + spit + (bSubstring(vendor.PurchasePhoneNumber, 15) == bSubstring(l_drformvendor.PurchasePhoneNumber, 15) ? "" : bSubstring(vendor.PurchasePhoneNumber, 15)) + spit + "" + spit + "" + spit + bSubstring(l_drformvendor.VATTypeID == vendor.VATTypeID ? "" : VatType.VatTypeName, 5) + spit + "" + spit + "" + spit + 0 + spit + 0 + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + "\r\n"; } else { logbll.InsertExportLogDetail(logId, "未找到Vendor历史数据!"); } #endregion break; case 3: ActionName = "R"; #region 重新激活 content = "" + spit + ActionName + spit + "" + spit + "VM" + spit + bSubstring(vendor.VendorCode, 5) + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + 0 + spit + 0 + spit + 0 + spit + "" + spit + "" + spit + "" + spit + "" + spit + 0 + spit + "" + spit + "" + spit + "" + spit + 0 + spit + "" + spit + 0 + spit + 0 + spit + 0 + spit + 0 + spit + 0 + spit + 0 + spit + "" + spit + "" + spit + 0 + spit + "" + spit + "" + spit + 0 + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + 0 + spit + 0 + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + 0 + spit + 0 + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + spit + "" + "\r\n"; #endregion break; } 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); UpdateVendorbyID(vendor.VendorID); } catch (Exception e) { logbll.InsertExportLogDetail(logId, "VendorCode:" + vendor.VendorCode + ",VendorName:" + vendor.VendorName + "" + ",错误信息:" + e.Message); return false; } return true; }
public void InsertVendor(int FormVendorID) { PurchaseDS.FormVendorRow FormVendorRow = new FormVendorBLL().GetFormVendorByID(FormVendorID)[0]; MasterData.VendorDataTable tb = new MasterData.VendorDataTable(); MasterData.VendorRow newVendorRow = tb.NewVendorRow(); MasterData.VendorTypeRow vendorTypeRow = new MasterDataBLL().GetVendorTypeById(FormVendorRow.VendorTypeID); int? Seq = 0; TAVendor.GenerateVenderCode(new MasterDataBLL().GetVendorTypeById(FormVendorRow.VendorTypeID).CompanyID, ref Seq); newVendorRow.VendorCode = Seq.ToString(); newVendorRow.VendorName = FormVendorRow.VendorName; newVendorRow.VendorAddress = FormVendorRow.VendorAddress; newVendorRow.City = FormVendorRow.City; newVendorRow.Postal = FormVendorRow.Postal; newVendorRow.ContactName = FormVendorRow.ContactName; newVendorRow.VendorTypeID = FormVendorRow.VendorTypeID; newVendorRow.CompanyID = vendorTypeRow.CompanyID; newVendorRow.PhoneNumber = FormVendorRow.PhoneNumber; newVendorRow.OneTimeVendor = FormVendorRow.OneTimeVendor; newVendorRow.HoldVendor = FormVendorRow.HoldVendor; newVendorRow.PurchaseingPostalCode = FormVendorRow.PurchaseingPostalCode; newVendorRow.AlphaSearchKey = FormVendorRow.AlphaSearchKey; newVendorRow.PurchasingContact = FormVendorRow.PurchasingContact; newVendorRow.PurchasingAddress = FormVendorRow.PurchasingAddress; newVendorRow.PurchasingCity = FormVendorRow.PurchasingCity; newVendorRow.PurchasePhoneNumber = FormVendorRow.PurchasePhoneNumber; newVendorRow.BankCode = FormVendorRow.BankCode; newVendorRow.MethodPaymentID = FormVendorRow.MethodPaymentID; newVendorRow.PaymentTermID = FormVendorRow.PaymentTermID; newVendorRow.TransTypeID = FormVendorRow.TransTypeID; newVendorRow.VATTypeID = FormVendorRow.VATTypeID; newVendorRow.BankName = FormVendorRow.BankName; newVendorRow.AccountNo = FormVendorRow.AccountNo; newVendorRow.BankNo = FormVendorRow.BankNo; newVendorRow.ACTypeID = FormVendorRow.ACTypeID; newVendorRow.BankCodeID = FormVendorRow.BankCodeID; newVendorRow.IsExport = false; if (!FormVendorRow.IsRemarkNull()) { newVendorRow.Remark = FormVendorRow.Remark; } newVendorRow.IsActive = true; newVendorRow.ActionType = (int)SystemEnums.VendorActionType.Add; tb.AddVendorRow(newVendorRow); this.TAVendor.Update(tb); FormVendorRow.VendorID = newVendorRow.VendorID; new PurchaseDSTableAdapters.FormVendorTableAdapter().Update(FormVendorRow); }