1 / 24

N-Tier Final Project

N-Tier Final Project. - Project : ABC Automotive Academy - Date : December 5 th , 2013 - Name : William H. Chung. The Purpose of this System. Create a System for an Instructor/Department Head.

Download Presentation

N-Tier Final Project

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. N-Tier Final Project - Project : ABC Automotive Academy - Date : December 5th, 2013 - Name : William H. Chung

  2. The Purpose of this System • Create a System for an Instructor/Department Head. • Allows an Instructor to control the borrowing, returning, and use of resources on-site by students, and adding, updating, deleting, retrieving a student. • Only Department Head can add resources and new user. • Implements 22 Business Requirements. • DB tables : Authenticate, Student, Resource, Loan, Payment

  3. DB Diagram

  4. Class Diagram

  5. ABC Automotive Structure • Business Object Layer • Authenticate, Loan, Payment, Resource, Student, StudentCUD • BusinessRules, Validation • LoanLookup, ResourceLookup, OverdueChargeLookup, StudentLookup • SQL Layer (Back End) • AuthenticateSQL, LoanSQL, PaymentSQL, ResourceSQL, StudentSQL • Data Access Layer • DAL, DALcnn

  6. ABC Automotive (Cont’d) • Presentation Layer (Front End) • Admin : AddResource, ManageUser • Loan : CheckoutResource, ReturenResource, MakePayment, OverdueChargeReport • Resource : ModifyResourceStatus, ReserveResource • Student : ManageStudent(Add, Update, Delete, Retrieve) • Startup : About, Login, SplashScreen, Main

  7. Business Rule 900 • User Privileges • Department Head with Administrative Privilege: • Add new login id and password information. • Add Resources • Instructor: All other modules • Applied into addResource and MangeUser If My.Settings.userType = UserType.DepartmentHead Then btnAdd.Enabled= True Else btnAdd.Enabled= False End If

  8. Business Rule 200 • Student Id • A unique school-assigned 8 digit id identifies each student. The number begins with the year the student first registered with ABC • Applied into validation.vb Function ValidateStudentId(ByValstudentId As String) As Boolean If (Not studentId.Substring(0, 4) Like "[1-9][0-9][0-9][0-9]") OrElse (Not ValidateLength(studentId, CheckLengthType.MustBeEqualTo, 8)) OrElse(Not IsNumeric(studentId)) OrElse (studentId.Substring(0, 4) <> Year(Date.Now).ToString) Then Throw New ArgumentException("Student id is invalid") Else Return True End If End Function

  9. Business Rule 201 • Student Status • Only active students can borrow resources • Applied into Loan.vb (SP: spIsActiveStudent) If Not BusinessRules.CheckStudentStatus(value) Then Throw New ArgumentException ("Student must be Active to check out .") End If ========================================================== DECLARE @tmpStatus bit SET @tmpStatus = (SELECT StudentStatus FROM student WHERE studentId = @studentId) IF (@tmpStatus = 0) SET @result = 'FALSE' ELSE SET @result = 'TRUE'

  10. Business Rule 202/203 • Start Date/End Date • Start Date must be less than the End Date • Applied into Student.vb (and DB constraint) If (value < _StartDate) Then ‘-- Setting End Date Throw New ConstraintException ("End date cannot be less than the start date.") End If ========================================================== ChkEndDate : ([EndDate] > [StartDate])

  11. Business Rule 204 • Program Option • Indicates the student is in either Regular or Block. • Set as Enum Public EnumProgramOption RegularProgram BlockRelease End Enum

  12. Business Rule 205/402 • Balance Due/Overdue Amounts Check • A student cannot borrow a resource nor be removed from the system if this amount is greater than $0.00 • Applied into Loan.vb (SP : spHasStudentBalanceDue) If BusinessRules.HasStudentBalanceDue(value) Then Throw New ArgumentException ("Student must pay his or her overdue to check out ") End If ========================================================== DECLARE @BalanceDuesmallmoney SET @BalanceDue = (SELECT BalanceDue FROM student WHERE studentId = @studentId) IF (@BalanceDue > 0) SET @result = 'TRUE' ELSE SET @result = 'FALSE'

  13. Business Rule 300 • Resource Primary Key • A unique system-assigned 8 digit id identifies each resource. • Applied into Resource.vb (Set as an Indentity) Public Shared Function ValidateResourceId(ByValresourceId As Integer) As Boolean If (resourceId < 10000000) OrElse (Not ValidateLength(resourceId.ToString, CheckLengthType.MustBeEqualTo, 8)) Then Throw New ArgumentException("Resource id is invalid") Else Return True End If End Function ========================================================== Set an IDENTITY SEED as 10,000,000

  14. Business Rule 301 • Resource Type • Indicates as DVD, Manual, Reference book. • Set as Enum Public EnumResourceType ManufacturerDVD ManufacturerReferenceManual NonManufacturerReferenceBook End Enum

  15. Business Rule 303 • Resource Status • Check whether a resource is Available, On Loan, or Not Available • Applied into CheckoutResource.vb & ReturnResource.vb If objResource.ResourceStatus <> ResourceStatus.OnLoan Then ' Check whether resource is on loan Return False End If =========================================================== If objResource.ResourceStatus <> ResourceStatus.AvailableThen ' Check whether resource is available Return False End If

  16. Business Rule 304 • Date Resource Removed from Library • Date a resource item was removed from the library due to loss or damage • Applied into stored procedures (SP: spUpdateStatus4LoanResource, spOverdueChargesReportRetrieve) IF @flag = 2(not returned) or 3(lost) UPDATE [resource] SET ResourceStatus = 2, RemovedDate = @today WHERE resourceid = (select resourceid from Loan where loanid = @loanid AND LoanStatus = 0) =========================================================== UPDATE [RESOURCE] SET ResourceStatus = 2, RemovedDate = @today FROM [RESOURCE] r INNER JOIN Loan L ON L.resourceid = r.resourceid WHERE r.ResourceStatus = 1 AND L.LoanStatus = 0 AND ABS(DATEDIFF(WEEKDAY, @today, L.DueDate)) >= 10

  17. Business Rule 306 • Reserve Status • The id of the reserving student is associated with this status • Applied into Loan.vb If CInt(Resource.ReserveStatus) = ReserveStatus.Reserved Then If (Resource.StudentIdWhoReserved <> value) Then Dim errMsg As String = Resource.StudentWhoReserved.FirstName& " " & Resource.StudentWhoReserved.LastName& " already reserved this resource." Throw New ArgumentException(errMsg) End If End If

  18. Business Rule 400/401 • Loan Period/Loan Return Time • A resource may be borrowed without penalty for 2 school days which includes the day the resource was borrowed • Applied into Loan.vb Private Function GetDueDate(checkoutDate As DateTime) As DateTime Dim tmpDueDate As Date If checkoutDate.DayOfWeek = DayOfWeek.ThursdayOrElse checkoutDate.DayOfWeek= DayOfWeek.Friday Then tmpDueDate = checkoutDate.AddDays(4) Else tmpDueDate = checkoutDate.AddDays(2) End If Return tmpDueDate.Date.AddHours(8).AddMinutes(30) End Function

  19. Business Rule 404/405 • Overdue Charge/Overdue Check • A student may not borrow any additional items until all overdue items are returned or paid for • Applied into Loan.vb (SP : spHasStudentBalanceDue) Public ReadOnly Property OverdueCharge As Decimal Implements ILoan.OverdueCharge Get If ReturnedDate > DueDate Then _OverdueCharge = DateDiff(DateInterval.Weekday, ReturnedDate, DueDate) * 5 Else _OverdueCharge = 0 End If Return _OverdueCharge End Get End Property

  20. Business Rule 406 • Non-return Charge • If an item fails to be returned by 8:30am of day 10, or is returned in a damaged state that warrants it being removed from the library, the student will be charged the replacement price of the item • Applied into SP : spOverdueChargesReportRetrieve UPDATE Loan SET LoanStatus = 3, ReplacemantPrice = OverdueCharge + r.PurchasePrice, OverdueCharge= 0, returneddate = @today FROM [RESOURCE] r INNER JOIN Loan l ON r.ResourceId = l.ResourceId WHERE LoanStatus = 0 AND ABS(DATEDIFF(WEEKDAY, @today, DueDate)) >= 10 AND r.RemovedDate = @today AND r.ResourceStatus = 2

  21. Business Rule 407 • Loan Status • When a resource is borrowed, the loan can have one of the states (On Loan, Returned, Returned Damaged, Not Returned) • Applied into Stored Procedures UPDATE Loan SET LoanStatus = 3, returneddate = @today, ReplacemantPrice= OverdueCharge + r.PurchasePrice FROM [RESOURCE] r INNER JOIN Loan l ON r.ResourceId = l.ResourceId WHERE LoanStatus = 0 AND r.ResourceStatus = 2 AND ABS(DATEDIFF(WEEKDAY, @today, DueDate)) >= 10 AND r.RemovedDate= @today

  22. Business Rule 408 • Loan Holdings • A student may borrow only one of each resource type at a time • Applied into spHasStudentSameLoanHolding IF EXISTS (SELECT * FROM Loan L INNER JOIN [Resource] r ON L.ResourceId = r.ResourceId WHERE L.StudentId = @StudentId AND @resourceType IN (SELECT ResourceType FROM Loan L INNER JOIN [Resource] r ON L.ResourceId = r.ResourceId WHERE ((L.StudentId = @StudentId AND L.LoanStatus = 0) OR (L.StudentId = @StudentId AND L.LoanStatus = 1 AND ABS(DATEDIFF(WEEKDAY, L.ReturnedDate, GETDATE())) < 1)))) SET @Result = 'TRUE' ELSE SET @Result = 'FALSE'

  23. Challenge • Needs to make the system more user friendly - Provide a better way to retrieve resources. - Provide Payment Reports • Protect the source - Save it frequently. • Lack of Time - Plan ahead and design it very carefully. - Make it more robust

  24. Thank You

More Related