Aptech Asp.net Assignments (5)

In this test you are required to develop a product browser page for an E-commerce company selling food and drink products. The database has been created and data are available, use the following information to access database:

Server local
Database Final
UID final
PWD Webform

Figure 1 is the diagram of the database schema:

Database Schema

Figure 1: Database Schema

Create a web form project on your local computer with the following information

Virtual Directory: http://localhost/C0305L_Final
Physical Directory : C:\inetpub\wwwroot\C0305L_Final

The product browser page is shown below:

Product browser page screen shot

Figure 2: Product browser page screen shot

As the application stores the image path for each product, you have to add those images to the web project application folder. Copy the folder \\Backup\mySetups\Images to your web project folder.

Implement the following logic for the page:

  1. When the page is loaded, display all product categories from Categories table to the Select Category drop down list.
    [Mark: 5]
  2. When Select button is clicked display all products with their information from Products table of the selected category in the list at the page bottom as shown in Figure 2. The products should be displayed horizontally on the page. The following product information should be displayed (refer to Figure 2 for details):a.    Product Image
    b.    Product Name
    c.    Price

    Update the Product Category label with the selected category.
    [Mark: 20]

  3. The product image should have a hyperlink at which when clicked will display that product details from Products and ProductDetails tables to the page. The following product information should be displayed (refer to Figure 2 for details):a.    Product Image
    b.    Product Name
    c.    Serving Size
    d.    Servings
    e.    Product specifications (from ProductDetails table)

    The currently-selected product should have a red border to indicate its selected status.
    [Mark: 25]

Aptech Asp.net Assignments (4)

Chapters: 11, 12, 13

Chapter 11:

  1. Create new project name EmployeeWS with type ASP.NET Web Service. Change name of Service1 to EmpWS.
  2. Write some method to export to the Web
    – A method to add new Employee
    – A method to get department name of employee. Parameters: empid, empname
    – A method to calculate man-hour for employee. Parameter: empid
  3. Use HTTP-GET to test Web service by press F5
  4. Use HTTP-POST to test Web service. Create a HTML page and place control to pass parameters.
  5. Create a Web proxy to test Web service.
  6. Create a new Web project  to test above dll.

Chapter 12:

  1. Create new project name MyWebControl with type Web Control Library. Change class name from WebControl1 to MyOwnWebControl.
  2. This composite control has two control DropDownList and DataGrid as below:

    MyWebControl

    MyWebControl

  3. Write some properties and method to do the following:
    – Set text display before DropDownList
    – Set data source for DropDownList (Customers table)
    – When user choose an item in the DropDownList, the appropriate data should be display in the DataGrid, according to the SelectedValue in the DropDownList (data in Bookings table according to CustID in DropDownList)
    – DataGrid has two columns, first column link to appropriate page to edit data in the Bookings table, second column to delete appropriate row in the Bookings table.
  4. To do work above, write the following properties:
    – Text : Set text display before DropDownList
    – SQLConnectionString : Set connection string for database
    – sqlTextForCombo : Sql command text to retrieve data for DropDownList
    – ErrorMessage : to get error while processing
    – SourceTableForDataGrid : Table name is data source for DataGrid
    – KeyFieldForDataGrid : DataKeyField for DataGrid
    – UpdateLink : link to the page to edit data in the Bookings table
  5. Write the following methods:
    – public bool SetDataSourceCombo(string textField, string valueField) : to set data source for DropDownList
    – private bool SetDataSourceDataGrid(string sqlText) : to set data source for DataGrid

Chapter 13:

  1. Create new Web form name Reports.aspx as below :
    Reports.aspx

    Reports.aspx

    In lower section is a CrystalReportViewer

  2. The doprdown list Period includes Day, Month, Quarter and Year. The doprdown list Order includes Ascending and Descending. The doprdown list Report Type includes Profit and Performance. The doprdown list By includes Profit, Room name.
  3. The doprdown list Room should be fill with data in table rooms.
  4. When button View Report click, show report with appropriate condition.
  5. Profit report contain 5 columns :
    – Sequence
    – Room name
    – Revenue (group by room)
    – Cost = 80% of Revenue
    – Profit = 20% of Revenue

Aptech Asp.net Assignments (3)

Chapters: 8, 9, 10

Chapter 8:

  1. Open form Depts.aspx in previous chapter and modify the interface as below:

    Depts.aspx

    Depts.aspx

  2. When Page_Load list box Department should be filled with data in Depts table
  3. When select each item in list Department, the appropriate data should be filled in text box control beside
  4. Create a web form name Repeater.aspx as below (using Repeater control):

    Repeater.aspx

    Repeater.aspx

  5. When Page_Load, two DropDownList should be filled with data in table Customer and Room
  6. When click button Show data , the Repeater control will display the data in table Bookings according to selection in DropDownList. If user choose radio button All, display all data in table Bookings. If user choose radio button Customer, display all data in table Bookings according to Customer choose in DropDownList Customers. If user choose radio button Room, display all data in table Bookings according to Room choose in DropDownList Rooms.

Chapter 9:

  1. Create form name EmpsSearch.aspx as below:
    EmpsSearch.aspx

    EmpsSearch.aspx

    - Check all validation in form if necessary, From birthday and To birthday must be date.
    – When Page_Load, load data from table Depts to DropDownList Department.

  2. When click Search:
    – Check whether user enter search condition in Employee name, From birthday and To birthday. If not, search only with sex and department condition, otherwise search with condition user enter.
    – When click Search, fill the result in DataList.
  3. When click Update, link to Emps.aspx and fill all data corresponding with employee.
    After edit data, click Save to update data to table Employees.

Chapter 10:

  1. Create new Class Library name DataHandling. Change name of Class1 to DataConn.
  2. Write some method to interaction with database:
    –    A method to add new booking room.
    –    A method to update booking room.
    –    A method to delete booking room.
    –    A method to set datasource for dropdown list.
    –    A method to get price of a room.
  3. Create form name Bookings.aspx as below:

    Bookings.aspx

    Bookings.aspx

  4. Make reference to above Class Library.
  5. In PageLoad, set datasource for Customer and Room.
  6. In Save button click, before saving, check from date must be greater than current date, to date must be greater than from date, and Price must be greater than or equal price for room in database.

Aptech Asp.net Assignments (2)

Chapters: 5, 6, 7


Chapter 5:

  1. Create a text file name users.txt contain a list of user name as following:

    quanlh
    tuanvt
    tienht
    hant
    /

    You can modify text file content as you wish.

  2. Create a form Startup.apsx as below:
    Startup.aspx

    Startup.aspx

    - Combobox should display user list in text file above
    – When you click Login, user name you select will be saved (Hint: use variable Session[“user”]) and the page redirect to inbox.aspx

  3. Create a form Inbox.aspx as below:
    Inbox.aspx

    Inbox.aspx

    - Use DataGrid to display message that other user send to you
    – Each message has a Reply button
    – When user click Reply, the page should redirect to SendMsg.aspx. Field Subject in SendMsg.aspx should display subject and prefix with RE. Combobox To in SendMsg.aspx should auto select user in From. Field Message in SendMsg.aspx should fill with Message.

  4. Create a form SendMsg.apsx as below:

    SendMsg.apsx

    SendMsg.apsx


    - From field should be read only
    – Combobox To should display user list in text file above
    – When click Send, this message should be sent to user in To field and when they login, their inbox should display the message.

  5. Send link to SendMsg.aspx; Inbox link to Inbox.aspx; Logout link to Startup.aspx:
  6. Hint:
    – Create for each user an Application object to save inbox for user
    – Use a DataTable to save data inbox. Table should has struct below
    Table name for each user according to user name:
    ID        int
    From        string
    Subject    string
    Message    string
    – This initialize code should place in Application_OnStart

Chapter 6

  1. Open form Custs.aspx in previous chapter:
    – When Save button click, check whether cookie name Custs exsited, if not, create it and add pair key/value, otherwise add pair key/value.
    – The key and value is value in Customer Name
    – Set property expire of cookie is 2 hours
  2. Open form Custs.aspx in previous chapter:
    – When Save button click, check whether cookie name Rooms exsited, if not, create it and add pair key/value, otherwise add pair key/value.
    – The key is the value in Room Number and the value is value in Price
    – Set property expire of cookie is 2 hours
  3. Create the form name Bookings.aspx as the following:
    Booking.aspx

    Booking.aspx

    - When Page_Load, read all value in cookie Cust and add to list Customer Name, and read all key name in cookie Rooms and add them to list Room Number
    – When user choose a Room Number (SelectedIndexChange), the Price should display the value corresponding with key in cookie Rooms.
    – Create RequiredFieldValidation for Form Date and To Date
    – Create CompareValidator for Form Date and To Date to check datatype enter is valid date


Chapter 7

  1. Open form Emps.aspx in previous chapter:
    – Check all validation in form if necessary.
    – When Page_Load, load data from table Depts to DropDownList Department.
    – When click Save, insert data to table Employees.
  2. Open form Custs.aspx in previous chapter:
    – Check all validation in form if necessary.
    – When click Save, insert data to table Customers.
  3. Open form Rooms.aspx in previous chapter:
    – Check all validation in form if necessary.
    – When click Save, insert data to table Rooms.

Aptech Asp.net Assignments

Chapters: 2, 3, 4

Chapter 2:

  1. Create a Web form name login.aspx using web control as following:
  2. Create a text file to save user name and password on the server as following format: user/password
    When user click on Login button, read text file and compare with user name and password user submit. If they match redirect to index.aspx page (create in previous assigment), otherwise message to user they enter incorrect user name and password.
    If user check Remember my user on this computer, using cookies to write user name on user’computer
  3. When Page_Load, if user login successful at the last time and choose Remember my user on this computer, textbox user name should be automatically fill with user name. Both textbox and checkbox should be disabled
  4. If user click on Login as different user button, both textbox user name and checkbox should be enabled. Textbox user name should cleared. The cookies you save on user’computer should be cleared value.

Chapter 3:

  1. Create 3 Web form using web control as following:
    Depts.aspx

    - Department Name and Direct Manager can not be empty
    – If user enter Number of Staff, check whether it is a valid number
    – When click Save, save data to an xml file name depts.xml

    <?xml version=”1.0″?>
    <?xml-stylesheet type=’text/xsl’?>
    <!DOCTYPE Department[<!ENTITY D ‘Depts’>]>
    <!–Save Department data–>
    <Dept>
    <DeptName>Management</ DeptName>
    <NumOfStaff>5</ NumOfStaff>
    <Manager>Tiến</ Manager>
    <Notes>Phòng này toàn là xếp cả thôi</Notes>
    </ Dept>

    Emps.aspx

    - Employee Name, Date of Birth, Title, Department, and Join Date can not be empty
    – When form load combo Title has following data

    Key Value
    Manager Manager
    Receptionist Receptionist
    Waiter Waiter
    Driver Driver
    Door Bell Door Bell
    Supervisor Supervisor

    - Department has following data

    Key Value
    1 Management
    2 Serving
    3 Customer service

    - Check Date of Birth and Join date is valid date and check employee age >= 18, join date >= date of birth + 18 year
    – When click Save, save data to an xml file name emps.xml

    Custs.aspx

    - Customer Name can not be empty
    – When click Save, save data to an xml file name custs.xml

  2. Clear should clear all form.
  3. Create links from index.aspx to each form above

Chapter 4:

  1. Create 1 Web form using web control as following:
    Rooms.aspx

    -    On form load, Room type has data list below

    Key Value
    1 First class – Double
    2 First class – Single
    3 Second class – Double
    4 Second class – Single
    5 Normal

    -    Using RequiredFieldValidator for Room Number, Floor and Price, if user does not enter data then show appropriate error message
    –    Using RegularExpressionValidator for Room Number, user must enter 3 number character
    –    Using RangerValidator for Floor, number of floor must be between 1 and 9
    –    Using CompareValidator for Price, user must enter data is Double

  2. Open form Depts.aspx you create in previous section and do the following:
    –    Using RequiredFieldValidator for Department Name, Number of Staff and Direct Manager, if user does not enter data then show appropriate error message
    –    Using CompareValidator for Number of Staff, user must enter data is Integer
    –    Using RegularExpressionValidator for Department Name and Direct Manager, user can only enter alphabetic character
  3. Open form Emps.aspx you create in previous section and do the following:
    –    Using RequiredFieldValidator for Employee Name, Date of Birth and Join Date, if user does not enter data then show appropriate error message
    –    Using CompareValidator for Date of Birth, user must enter data is Date and employee age must be >= 18
    –    Using CompareValidator for Join Date, user must enter data is Date and Join Date must be >= Date of Birth + 18 years
    –    Using RegularExpressionValidator for Employee Name, user can only enter alphabetic character
  4. Open form Custs.aspx you create in previous section and do the following:-    Insert an combobox District above Phone as below-    Add 7 districts in Hà nội to combobox
    –    After user choose an District and enter Phone number, using CustomValidator to check whether phone number is match with District.
    Example: if district is Đống Đa, the first character in phone number must be 5, not the others (Ex: 5235649 not 8235649)

Bài tập ASP.Net căn bản

  1. Thiết kế 1 trang asp.net có tên ServerDate.aspx với yêu cầu như sau:

    – 01 label có id là lblServerDate.
    – 01 button có id btnGetServerDate và text là Get.
    – Khi click vào nút Get thì lblServerDate sẽ hiển thị thời gian hiện tại của server.
  2. Thiết kế 1 trang asp.net có tên SayHello.aspx với yêu cầu như sau:


    Hình 1: Người dùng load trang lần đâu


    Hình 2: Sau khi click nút Submit

    - 01 label có id là lblHelloText, 01 textbox có id là txtName, 01 button có id là btnSubmit (Xem hình minh họa).
    – Khi người dùng load trang lần đầu thì lblHelloText hiển thị nội dung là: It’s now: [thời gian của server].
    – Khi người dùng nhập tên vào txtName và click vào btnSubmit thì lblHelloText sẽ hiển thị nội dung: Hello [Nội dung textbox]! Happy codding!.

  3. Phát triển ý 2, kiểm tra xem người dùng đã nhập tên chưa, nếu chưa nhập thì thông báo yêu cầu nhập tên.
    Gợi ý: Sử dụng RequiredFieldValidator