private void btnLoad_Click(object sender, EventArgs e) { myScreen = myVendorsService.getScreenByVendID(tbVendID.Text); if (myScreen.errorMessage != "") { MessageBox.Show("Error: " + myScreen.errorMessage); return; } btnUpdate.Enabled = true; tbScreen.Text = ctStandardLib.ctHelper.serializeObject(myScreen).Replace("><", ">" + Environment.NewLine + "<"); }
//Creates an empty new generic batch private void btnNew_Click(object sender, EventArgs e) { myScreen = myVendorsService.getNewscreen(null); //we need to generate an invtID, for example purposes we will just use our counter and a random string myScreen.myVendor.VendId = "VEND" + myCommonsService.getNextCounter("VENDID").Tables[0].Rows[0]["OUTAMT"].ToString().Trim(); /*example setting fields*/ myScreen.myVendor.Name = "my test vendor" + myScreen.myVendor.VendId; myScreen.myVendor.TaxId00 = myVendorsService.getTaxIDsByTaxIDAndType("", "")[0].TaxId; //pick first entry myScreen.myVendor.Country = myVendorsService.getCountriesByCountryID("US")[0].CountryID; //pick first entry myScreen.myVendor.State = myVendorsService.getStatesByStateProvID("NJ")[0].StateProvId; //pick first entry myScreen.myVendor.CuryId = myVendorsService.getCurrencyByCuryID("")[0].CuryId; //pick first entry //myScreen.myVendor.LCCode = myVendorsService.getLandedCostsByID("")[0].LCCode;//pick first entry myScreen.myVendor.Terms = myVendorsService.getTermsByTermsID("")[0].TermsId; //pick first entry myScreen.myVendor.ClassID = myVendorsService.getVendClassesByClassID("")[0].ClassID; //pick first entry /*example setting fields*/ try { ctDynamicsSL.financial.accountsPayable.maintenance.vendorMaintenance.Snote myVendorNote = new ctDynamicsSL.financial.accountsPayable.maintenance.vendorMaintenance.Snote(); myVendorNote.sNoteText = "My test vendor note"; myScreen.vendorNote = myVendorNote; } catch { } myScreen.errorMessage = ""; try { ctDynamicsSL.financial.accountsPayable.maintenance.vendorMaintenance.screen validateScreen = myVendorsService.editScreen("VALIDATEONLY", myScreen); if (validateScreen.errorMessage != "") { MessageBox.Show("Error: " + validateScreen.errorMessage); return; } } catch { } myScreen = myVendorsService.editScreen("ADD", myScreen); if (myScreen.errorMessage != "") { btnUpdate.Enabled = false; tbVendID.Text = ""; tbScreen.Text = ctStandardLib.ctHelper.serializeObject(myScreen).Replace("><", ">" + Environment.NewLine + "<"); MessageBox.Show("Error: " + myScreen.errorMessage); return; } else { tbVendID.Text = myScreen.myVendor.VendId.Trim(); btnLoad.PerformClick(); } }
//Used to save a batch that has been loaded private void btnUpdate_Click(object sender, EventArgs e) { if (myScreen == null) { MessageBox.Show("You must load a vendor first!"); return; } myScreen.errorMessage = ""; MessageBox.Show(ctStandardLib.ctHelper.serializeObject(myScreen).Replace("><", ">" + Environment.NewLine + "<")); myScreen = myVendorsService.editScreen("UPDATE", myScreen); if (myScreen.errorMessage != "") { MessageBox.Show("Error: " + myScreen.errorMessage); } else { MessageBox.Show("Save complete!"); } }