Lab3 WindowForms EN
Lab3 WindowForms EN
EXERCISE 1
Windows Form Application – Basic
* Content:
- Create a basic Windows Form application that calculates the service charge for a dentist
visit.
- For each customer, the services provided include: teeth removal, lime shaving, dental
imaging and fillings. Each type will have its own cost. Finally, the total cost of the guest
must pay. Note: only charge when the customer name information has been entered (if
this information is not available, the program generates MessageBox alert).
- The application has a simple interface below.
Guideline:
1. Create a Windows Form application named DentalPaymentApp by following these steps
a. Create a new project (Ctrl+Shift +N),
b. In the new project window select Visual C # .Net - Windows
c. For the template section, select Windows Forms Application
d. Set name of the project in the Name section
2. After completing the steps on VS.NET will generate a sample Windows Form project,
allowing programmers to start building applications. The interface of VS.NET 2005 for the
newly created application is as shown in Figure 3 below.
Doing:
- Way 2: Select the button to create a handler, then click the event tab in the Properties
window, double click the Click item in the event window.
1. Create a cash register function, this function is activated when the "Cash register" button
is selected. Describe the GetPay () function as follows (GetPay () is a member method of the
main Form class:
+ Check if the customer name is entered or not?
+ If not: export notice, request enter guest name.
+ Imported: perform the following steps
Total = 0
If (cạo vôi) Total += 100.000
If ( tẩy trắng) Total += 1.200.000
If ( chụp hình răng) Total +=200000
Total += (số răng trám)*80000
Export amount to TextBox txtTotal
Result:
1. If customer name is not entered: alert message box will arise
EXERCISE 2
Windows Form Application – Basic
* Content:
Building an application to simulate the Security Panel device as follows:
A lab wants to set up a Security Panel outside the door. Only authorized individuals are
allowed to enter and each login they must enter the provided security code. The following
security code (aka access code) is considered valid and provided to the employee groups as
follows:
Value Group
1645 or 1689 Technicians
8345 Custodians
9998, 1006 – 1008 Scientist
Once you enter the access code, there are two states: granted or denied. All access
information will be displayed in an information box below the keypad. If access is granted, the date,
time, group (technician, custodian, scientist) will be displayed in the info box. If access is denied,
the date, time and "Access denied" information will be displayed in the box below. In addition, if a
user only clicks a security code number, it will display a notice of the date, time and "Restricted
Access". An illustration of the interface of the Security Panel application
Guideline:
1. Design the Form as shown in Figure 1
a. Describe the controls on the form as shown in Figure 2:
EXERCISE 3
Windows Form Application – Advanced
1. Create a System Login Form using the following form, then save it with the name
Dangnhap.vb:
Hình 1
Requirement:
- Click on Việt Radio Button, the interface is as shown in Figure 1. Click on Anh
Radio Button, the interface is as in Figure 2 below:
Hình 2
Similarly: Click Radio Button VI, the interface is as shown in Figure 1. Click
on Radio Button EN, the interface is as in Figure 2.
- When the cursor is in the textbox, the textbox background is pink. In contrast, the
white background.
- If the TextBox is empty, the * sign is red. Contrast the blue * sign.
- Click the RESET button (or LÀM MỚI) to set empty for the TextBox.
- Click on the EXIT (or THOÁT) button, a message will appear:
If OK, exit the program. Clicking Cancel does not exit the program.
- When LOGIN (or ĐĂNG NHẬP) button is pressed:
+ Check if the TextBox has enough information?
+ If you enter Username as “Admin” or “admin” and Password as “123456”, a
window will appear (In item 2).
2. Create the Form to perform the calculation according to the following form and save
it with the name Pheptinh.vb:
Requirement:
- When the cursor is in the textbox, the textbox background is pink. In contrast, the
white background.
- If the TextBox is empty, the * sign is red. Contrast the blue * sign.
- Click the RESET button (or REFRESH) to delete the TextBox.
- After Enter a, Enter b, select the calculation and press the THỰC HIỆN button,
the result will display on the Kết quả TextBox.
- Clicking the Next button will display the message "Do you want to go to the next
article?". If Yes is selected, go to the next window (In item 3). If you select No,
the window will remain.
3. Create the following form and save it as a name Tuychon.vb:
Add the Next button. Click the Next button to go to the Form in section 4
Requirement:
- When the cursor is in the textbox, the textbox background is pink. In contrast, the
white background.
- If the TextBox is empty, the * sign is red. Contrast the blue * sign.
- Click the RESET button, set empty for the TextBox.
- Require:
+ Enter enough information on the TextBox.
+ Only numbers are allowed.
- After entering enough and correct information, select one of the calculation
options and click the OK button, the corresponding calculation results will show
in place of Label3.
4. Create the following form and save it as a name Random.vb:
Requirement:
- Select or enter a number in NumericUpDown to select the number of students to
randomly select topics.
Pressing the PLAY button will display a random number from 1 to the selected
number.
Pressing the PLAY button will bring up another random number from 1 to 34,
different from the previous one. Until the selected number runs out, the dialog box is
displayed:
FPT University Collection and Edit
7/19/2021Created by X31
WindowsForm using C# 2020
EXERCISE 4
Windows Form Application – Advanced
Requirement: Use the ProgressBar control to run the process, after a period of time then
automatically switches to another window (As in item 2).
2. Create the following form and save it as a name frmMain.vb:
Add the Lunar button under the Exit button. When you press the Lunar button will
switch to a new window (As in item 3).
Requirement:
- Clicking Exit will exit the program.
- Clicking on the options will display the corresponding Club Logo (Image may be
changed if not available).
Guideline: To display the image, we do the following
pic1.Image = My.Resources.logo1;
Inside:
+ pic1 is the name of the PictureBox control.
+ logo1 is the name of the image added in Resource.
Requirement:
- When the cursor is in the textbox, the textbox background is pink. In contrast, the
white background.
- Click the Exit button and exit this window. (Me.Close())
- Entering the Calendar Year and clicking the View button will display the
corresponding lunar year.
Guideline:
- Declare 2 array variables can and chi.
- In Load Form mode, initialize values for 2 global variables as follows:
chi[1] = "Thân";
chi[2] = "Dậu";
chi[3] = "Tuất";
chi[4] = "Hợi";
FPT University Collection and Edit
7/19/2021Created by X31
WindowsForm using C# 2020
chi[5] = "Tý";
chi[6] = "Sửu";
chi[7] = "Dần";
chi[8] = "Mão";
chi[9] = "Thìn";
chi[10] = "Tỵ";
chi[11] = "Ngọ";
chi[12] = "Mùi";
can[1] = "Canh";
can[2] = "Tân";
can[3] = "Nhâm";
can[4] = "Quý";
can[5] = "Giáp";
can[6] = "Ất";
can[7] = "Bính";
can[8] = "Đinh";
can[9] = "Mậu";
can[10] = "Kỷ";
- Procedure when clicking the View button:
Private void btnView_Click()
{
int v_chi, v_can;
String v_result;
v_chi = Int32.parse(txtDuong.Text) % 12;
v_can = Int32.parse (txtDuong.Text) % 10;
v_result = can[v_can + 1] & " " & chi[v_chi + 1];
txtAm.Text = v_result;
txtDuong.Focus();
}