//Test transaction for valid GLs and customer public bool validateTransaction(TransactionTbl transaction) { bool valid = true; AccountingSystemV2Entities1 db = new AccountingSystemV2Entities1(); //test GL1 for existence GeneralLedgerTbl foundGL = (from d in db.GeneralLedgerTbls where d.generalLedger == transaction.gl1 select d).Single(); if (foundGL == null) { valid = false; throw new System.ArgumentException("GL " + transaction.gl1 + " not found in GL table."); } //test gl2 foundGL = (from d in db.GeneralLedgerTbls where d.generalLedger == transaction.gl2 select d).Single(); if (foundGL == null) { valid = false; throw new System.ArgumentException("GL " + transaction.gl2 + " not found in GL table."); } //test gl3 foundGL = (from d in db.GeneralLedgerTbls where d.generalLedger == transaction.gl3 select d).Single(); if (foundGL == null) { valid = false; throw new System.ArgumentException("GL " + transaction.gl3 + " not found in GL table."); } //test gl4 foundGL = (from d in db.GeneralLedgerTbls where d.generalLedger == transaction.gl4 select d).Single(); if (foundGL == null) { valid = false; throw new System.ArgumentException("GL " + transaction.gl4 + " not found in GL table."); } //test customer CustomerTbl foundCustomer = (from d in db.CustomerTbls where d.CustomerID == transaction.customer select d).Single(); if (foundCustomer == null) { valid = false; throw new System.ArgumentException("Customer not found in Customer table."); } return valid; }
public void TestValidateTransaction() { BusinessLayer myBL = new BusinessLayer(); TransactionTbl myTransaction = new TransactionTbl(); myTransaction.gl1 = "5540"; myTransaction.gl2 = "5541"; myTransaction.gl3 = "1042"; myTransaction.gl4 = "2142"; myTransaction.project = "0416"; myTransaction.fund = "B40"; myTransaction.customer = 23; myTransaction.status = "HELD"; myTransaction.description = "Record Cash Outlays"; myTransaction.amount = 50.55; Assert.IsTrue(myBL.validateTransaction(myTransaction)); }
protected void Button1_Click(object sender, EventArgs e) { TransactionTbl myTransaction = new TransactionTbl(); myTransaction.gl1 = this.TextBox1.Text; myTransaction.gl2 = this.TextBox2.Text; myTransaction.gl3 = this.TextBox3.Text; myTransaction.gl4 = this.TextBox4.Text; myTransaction.fund = this.TextBox5.Text; myTransaction.project = this.TextBox6.Text; myTransaction.customer = Convert.ToInt32(this.TextBox7.Text); myTransaction.amount = Convert.ToDouble(this.TextBox8.Text); var transactionRepo = Service.RepositoryFactory.Create("Transaction"); transactionRepo.Insert(myTransaction); this.TextBox9.Text = "Success"; }
public string enterTransaction(string gl1, string gl2, string gl3, string gl4, int customerCode, string fund, string description, string project, float amount) { string status = "Unposted"; TransactionTbl myTransaction = new TransactionTbl(); myTransaction.gl1 = gl1; myTransaction.gl2 = gl2; myTransaction.gl3 = gl3; myTransaction.gl4 = gl4; myTransaction.description = description; myTransaction.fund = fund; myTransaction.project = project; myTransaction.customer = customerCode; myTransaction.status = "Held"; myTransaction.amount = amount; var transactionRepo = Service.RepositoryFactory.Create("Transaction"); transactionRepo.Insert(myTransaction); return status; }
public void InsertTransactionUsingRepo() { var transactionRepo = new DataRepository<TransactionTbl>(); TransactionTbl myTransaction = new TransactionTbl(); myTransaction.gl1 = "4801"; myTransaction.gl2 = "4802"; myTransaction.gl3 = "1016"; myTransaction.gl4 = "2108"; myTransaction.description = "Record UDO"; myTransaction.status = "Held"; myTransaction.fund = "A1R"; myTransaction.project = "1442"; myTransaction.customer = 1; myTransaction.amount = 50.50; transactionRepo.Insert(myTransaction); }