private void addVendor(IVMain.ivpwsMAIN001PortTypeClient client) { IVMain.AddVendorRequest request = new IVMain.AddVendorRequest(); IVMain.Service_AddVendorType addVen = new IVMain.Service_AddVendorType(); request.Service_AddVendor = addVen; addVen.CMSDataBase = "CMSDATEDI"; addVen.VendorName = "TNToys"; addVen.VendorCode = "1023"; addVen.AddressLine01 = "1 Sakura Drive"; try { IVMain.AddVendorResponse response = ((ivpwsMAIN001PortType)client).AddVendor(request); //CMS_ServiceResponse_AddVendorType; IVMain.CMS_ServiceResponseType GlobalResponse = response.CMS_ServiceResponse; Console.WriteLine(GlobalResponse.Messages); //AddPORequisitionResponse response = ((ivpwsNPO001PortType)client).AddPORequisition(request); //CMS_ServiceResponse_AddPORequisitionType addGlobalPOReqResponse = response.CMS_ServiceResponse_AddPORequisition; //Console.WriteLine(addGlobalPOReqResponse.RequisitionNumber); } catch { } }
public void AddVendor(Vendor ven, string database) { ERMA.IVMain.ivpwsMAIN001PortTypeClient client = new ivpwsMAIN001PortTypeClient("ivpwsMAIN001HttpSoap12Endpoint"); // set so that service manager uses custom credentials class instead of default. client.ChannelFactory.Endpoint.Behaviors.Remove <System.ServiceModel.Description.ClientCredentials>(); client.ChannelFactory.Endpoint.Behaviors.Add(new CustomCredentials()); // set the credentials and path to the certificate. client.ClientCredentials.UserName.UserName = ERMA.Properties.Settings.Default.WebUser.ToString(); client.ClientCredentials.UserName.Password = ERMA.Properties.Settings.Default.WebPassword.ToString().ToLower(); client.ClientCredentials.ClientCertificate.SetCertificate(System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine, System.Security.Cryptography.X509Certificates.StoreName.My, System.Security.Cryptography.X509Certificates.X509FindType.FindBySerialNumber, "4d 00 eb c7"); IVMain.AddVendorRequest request = new IVMain.AddVendorRequest(); IVMain.Service_AddVendorType addVen = new IVMain.Service_AddVendorType(); request.Service_AddVendor = addVen; addVen.RequestID = "MAINID".ToUniqueID(); addVen.RequestMode = "MAINMODE".ToUniqueID(); addVen.CMSDataBase = database; addVen.ServPlntCod = "DFT"; addVen.ServLang = "ENU"; //Page 1 addVen.VendorCode = ven.VendorCode; addVen.VendorName = ven.VendorName; addVen.AddressLine01 = ven.Address1; addVen.AddressLine02 = ven.City + ", " + ven.State; addVen.City = ven.City; addVen.PostalCode = ven.Zip; addVen.ProvinceCode = ven.State; addVen.WebPageAddress = ven.WebSite; addVen.TelephoneNumber = ven.BusinessPhone; addVen.FAXNumber = ven.FaxPhone; addVen.TermsCode = ven.PaymentTerms; addVen.TaxGroupCode = ven.TaxGroupCode; addVen.GoodsTaxRateCode = ven.GoodsTaxRateCode; addVen.ServicesTaxRateCode = ven.ServicesTaxRateCode; addVen.VendorStatus = ven.VendorStatus; addVen.InactiveReason = ven.InactiveReason; addVen.CountryCode = ven.Country; addVen.ContactName = ven.Contact; addVen.DunsNumber = ven.DunsNum; // Federal Tax ID = ven.FederalTaxID; // Freight Charges addVen.RemitToVendorCode = ven.RemitTo; addVen.APBankCode = ven.ApBank; addVen.YTDPurchasesAmount = ven.YtdPurchases; addVen.FOBCode = ven.FobCode; addVen.OutsideServiceStockroomCode = ven.OsStockroom; addVen.VendorClass = ven.VendorClass; addVen.CurrencyCode = ven.Currency; addVen.MinorityIndicatorFlag = ven.MinorityFlag; addVen.AutoVoucherFlag = ven.AutoVoucher; addVen.ChequeOrVoucherFlag = ven.ChequeVoucher; addVen.Applicable1099 = ven.T1099; //Page 2 addVen.CreatePlanningSchedule = ven.CreatePlanningSchedule; addVen.PlanningScheduleFrequency = ven.PlanningScheduleFrequency; addVen.PlanningScheduleDay = ven.PlanningScheduleDay; addVen.PlanningScheduleDate = ven.PlanningScheduleDate; addVen.CreateShippingSchedule = ven.CreateShippingSchedule; addVen.ShippingScheduleFrequency = ven.ShippingScheduleFrequency; addVen.ShippingScheduleDay = ven.ShippingScheduleDay; addVen.ShippingScheduleDate = ven.ShippingScheduleDate; addVen.GenerateScoreCard = ven.GenerateScoreCard; addVen.ScanSupplierSerialNbrs = ven.ScanSupplierSerialNum; addVen.POSendMode = ven.PoSendMode; addVen.ShippingLeadTime = ven.ShippingLeadTime; addVen.ShippingLeadTimeUnit = ven.ShippingLeadTimeUnit; addVen.RoundShippingHoursToDays = ven.RoundShippingHoursToDays; // Skip W. Days for EDI Exp Date addVen.RequireEDIRemittanceAdvice = ven.RequireEDIRemittanceAdvice; addVen.PartialPaymentAllowedForEDI = ven.EDIPartialPaymentAllowed; addVen.APControl = ven.ApVoucherControl; //Page 3 addVen.ProcessSerializedDtls = ven.ProcessSerializedInASN; addVen.TimeZoneCode = ven.TimeZone; addVen.FederalID = ven.FederalID; addVen.VendorType = ven.VendorType; addVen.VendorDumpingClass = ven.DumpingClass; addVen.CarrierCode = ven.DefaultCarrier; addVen.CustomBrokerCode = ven.DefaultCustomBkr; addVen.USRDEFVerificationTemplate = ven.UserVerTempl; addVen.QCInspectorCode = ven.QcInspector; addVen.InitialDisplayScheduleRelease = ven.InitialDisplayScheduleRelease; addVen.RepairLocation = ven.RepairLocation; addVen.POCommodityCategoryCode = ven.CommodityCategory; addVen.ASNMapping = ven.ASNMapping; //Page 4 addVen.AutoPrintPOWhenApproved = ven.AutoPrintApprovedPO; addVen.ScanFormat2D = ven.TwoDScanFormat; addVen.DefaultTo2DScan = ven.DefaultTo2DScan; addVen.Override2DScanLotNumber = ven.Override2DScanLotNum; addVen.DefaultSupplierCode = ven.DefaultSupplierCode; addVen.LanguageCode = ven.PrintLanguage; addVen.VoucherWithoutReceiptRequireNotepad = ven.VoucherWithOutReceiptRequiresNotepad; addVen.NotesForRecurringVouchers = ven.EnterNotesforRecurringVouchers; addVen.MinimumOrderAmount = ven.MinimumOrderAmount; addVen.FreeFreightThreshold = ven.FreeFreightThreshold; addVen.DisplayPrintSendMRPNotification = ven.DisplayMRPNotification; addVen.ImportVendorFlag = ven.ImportVendor; addVen.EasyBusinessAsnUpdatePoShipmentsInTransit = ven.EZASNUpdatePOShpmntInTransit; //Page 5 addVen.DefaultEdiSpecialHandlingCode = ven.DefaultEDISpecialHandlingCode; addVen.CommodityAuthorization = ven.CommodityAuthorization; addVen.VendorReturnPrimaryAsnTemplateCode = ven.VendorReturnASNVerificationTemplate; addVen.OutsideServicePrimaryAsnTemplateCode = ven.OutsideServiceASNVerificationTemplate; addVen.RepairPrimaryAsnTemplateCode = ven.RepairASNVerificationTemplate; addVen.SourcePlantCode = ven.SourcePlantCode; addVen.SupplyingPlantCode = ven.SupplyingPlantCode; addVen.OSScrapTransactionReasonCode = ven.OSScrapTransReason; addVen.Incoming810QtyToleranceCheck = ven.Incoming810QuantityToleranceRangeCheck; addVen.Incoming810QtyToleranceLowerRangePerc = ven.RangeLower.ToString(); addVen.Incoming810QtyToleranceUpperRangePerc = ven.RangeUpper.ToString(); addVen.Tier2ScdVendor = ven.Tier2SCDVendor; //Page 6 addVen.DusDiscDateTermCalcMethod = ven.DiscountDueDateFromTermCode; addVen.UseForeignFFL = ven.UseForeignFFL; addVen.AutoImportPostIncomingNonSCDASN = ven.AutoImportPostIncomingNonSCDASN; //EFT addVen.ARContact = ven.ArContact; addVen.ARPhoneNumber = ven.ArPhoneNumber; addVen.ARFaxNumber = ven.ArFaxNumber; addVen.EFTBankCode = ven.EFTBankCode; //Deposit Transit try { IVMain.AddVendorResponse response = ((ivpwsMAIN001PortType)client).AddVendor(request); //CMS_ServiceResponse_AddVendorType; IVMain.CMS_ServiceResponseType GlobalResponse = response.CMS_ServiceResponse; //Console.WriteLine(GlobalResponse.Messages); } catch { } }