//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 batch first!"); return; } myScreen.myAPDoc.VendId = myVAObj.getVendorsByID(tbVendID.Text)[0].VendId; foreach (ctDynamicsSL.financial.accountsPayable.input.voucherAndAdjustmentEntry.APTran tmpTran in myScreen.myAPTran) { tmpTran.VendId = myScreen.myAPDoc.VendId; tmpTran.CuryTranAmt = tmpTran.CuryUnitPrice * tmpTran.Qty; } MessageBox.Show(ctStandardLib.ctHelper.serializeObject(myScreen).Replace("><", ">" + Environment.NewLine + "<")); myScreen = myVAObj.editScreen("UPDATE", myScreen); if (myScreen.errorMessage != "") { MessageBox.Show("Error: " + myScreen.errorMessage); return; } tbRefNbr.Text = myScreen.myAPDoc.RefNbr; tbVendID.Text = myScreen.myAPDoc.VendId; gvAPTran.DataSource = myScreen.myAPTran; btnUpdate.Enabled = true; tbScreen.Text = ctStandardLib.ctHelper.serializeObject(myScreen).Replace("><", ">" + Environment.NewLine + "<"); }
private void btnLoadBatch_Click(object sender, EventArgs e) { myScreen = myVAObj.getScreenByBatNbr(tbBatNbr.Text); if (myScreen.errorMessage != "") { MessageBox.Show("Error: " + myScreen.errorMessage); return; } tbRefNbr.Text = myScreen.myAPDoc.RefNbr; tbVendID.Text = myScreen.myAPDoc.VendId; gvAPTran.DataSource = myScreen.myAPTran; 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 = myVAObj.getNewscreen(null); if (tbVendID.Text.Trim() == "") { tbVendID.Text = myScreen.myAPDoc.VendId = myVAObj.getVendorsByID("")[0].VendId.Trim();//pick first vendID available } myScreen.myAPDoc.VendId = myVAObj.getVendorsByID(tbVendID.Text)[0].VendId; myScreen.myAPDoc.Terms = myVAObj.getVendorsByID(tbVendID.Text)[0].Terms; myScreen.myAPDoc.PmtMethod = myVAObj.getVendorsByID(tbVendID.Text)[0].PmtMethod; myScreen.myAPDoc.DocType = "VO"; //myScreen.myAPDoc.Terms = myVAObj.getTermsByID("")[0].TermsId;//pick first termsID available myScreen.myAPDoc.CuryOrigDocAmt = 100; myScreen.myAPDoc.Status = "A"; //myScreen.myAPDoc.Acct = myVAObj.getAcctXrefsByAcct("", myScreen.myBatch.CpnyID)[0].Acct;//get first acct //myScreen.myAPDoc.Sub = myVAObj.getSubXrefsBySub("", myScreen.myBatch.CpnyID)[0].Sub; //get first sub ctDynamicsSL.financial.accountsPayable.input.voucherAndAdjustmentEntry.Snote batchNote = new ctDynamicsSL.financial.accountsPayable.input.voucherAndAdjustmentEntry.Snote(); batchNote.sNoteText = "test batch note"; myScreen.batchNote = batchNote; ctDynamicsSL.financial.accountsPayable.input.voucherAndAdjustmentEntry.Snote documentNote = new ctDynamicsSL.financial.accountsPayable.input.voucherAndAdjustmentEntry.Snote(); documentNote.sNoteText = "test document note"; myScreen.documentNote = documentNote; List <ctDynamicsSL.financial.accountsPayable.input.voucherAndAdjustmentEntry.APTran> apTrans = new List <ctDynamicsSL.financial.accountsPayable.input.voucherAndAdjustmentEntry.APTran>(); try { ctDynamicsSL.financial.accountsPayable.input.voucherAndAdjustmentEntry.APTran tmpTran = myVAObj.getNewAPTran(null); tmpTran.CpnyID = myScreen.myBatch.CpnyID; tmpTran.LineType = "N"; tmpTran.Acct = myVAObj.getAcctXrefsByAcct("", myScreen.myBatch.CpnyID)[0].Acct; //get first acct tmpTran.Sub = myVAObj.getSubXrefsBySub("", myScreen.myBatch.CpnyID)[0].Sub; //get first sub tmpTran.TranDesc = "line 1"; tmpTran.trantype = "VO"; tmpTran.LineType = "N"; tmpTran.DrCr = "D"; tmpTran.Qty = 1; tmpTran.CuryUnitPrice = 100; tmpTran.CuryTranAmt = 100; tmpTran.VendId = myScreen.myAPDoc.VendId; apTrans.Add(tmpTran); } catch { } try { ctDynamicsSL.financial.accountsPayable.input.voucherAndAdjustmentEntry.APTran tmpTran = myVAObj.getNewAPTran(null); tmpTran.CpnyID = myScreen.myBatch.CpnyID; tmpTran.LineType = "N"; tmpTran.Acct = myVAObj.getAcctXrefsByAcct("", myScreen.myBatch.CpnyID)[0].Acct; //get first acct tmpTran.Sub = myVAObj.getSubXrefsBySub("", myScreen.myBatch.CpnyID)[0].Sub; //get first sub tmpTran.TranDesc = "line 2"; tmpTran.trantype = "VO"; tmpTran.LineType = "N"; tmpTran.DrCr = "D"; tmpTran.Qty = 2; tmpTran.CuryUnitPrice = 100; tmpTran.CuryTranAmt = 200; tmpTran.VendId = myScreen.myAPDoc.VendId; apTrans.Add(tmpTran); } catch { } myScreen.myAPTran = apTrans.ToArray(); myScreen = myVAObj.editScreen("ADD", myScreen); if (myScreen.errorMessage != "") { btnUpdate.Enabled = false; tbBatNbr.Text = ""; tbRefNbr.Text = ""; gvAPTran.DataSource = null; tbScreen.Text = ctStandardLib.ctHelper.serializeObject(myScreen).Replace("><", ">" + Environment.NewLine + "<"); MessageBox.Show("Error: " + myScreen.errorMessage); return; } else { tbBatNbr.Text = myScreen.myBatch.BatNbr; btnLoadBatch.PerformClick(); } }