You are on page 1of 6

Lab 7 – Quiz Test Application

1. Form Log In
Interface

Figure 1 Form Log In

Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuizTestApp
{
public partial class frmLogIn : Form
{
public frmLogIn()
{
InitializeComponent();
}

private void button1_Click_1(object sender, EventArgs e)


{
txtUsername.Clear();
txtPassword.Clear();
txtUsername.Focus();
}

private void frmLogIn_Load(object sender, EventArgs e)


{

private void btnRegister_Click(object sender, EventArgs e)


{
QuizTestApplication insideForm = new QuizTestApplication();
insideForm.TopLevel = true;
insideForm.Show();
}

private void btnSignIn_Click(object sender, EventArgs e)


{
string user = txtUsername.Text;
string password = txtPassword.Text;
DialogResult notification;

if (user == "admin" && password == "admin")


{
// Login successfully, open main form
notification = MessageBox.Show("Login Successful! ", "Login
Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (notification == DialogResult.OK)
{
frmQuiz mainForm = new frmQuiz();
mainForm.Show();
this.Hide();
}
}
else
{
// Wrong login, request to login again
MessageBox.Show("Username or password is incorrect. Please try
again!", "Wrong Login", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtUsername.Clear();
txtPassword.Clear();
txtUsername.Focus();
}
}
}
}
2. Form Registration
Interface

Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuizTestApp
{
public partial class QuizTestApplication : Form
{
public QuizTestApplication()
{
InitializeComponent();
}

private void frmRegistation_Load(object sender, EventArgs e)


{

private void btnReset_Click(object sender, EventArgs e)


{
txtUsername.Clear();
txtPhone.Clear();
txtPassword.Clear();
txtConfirmPassword.Clear();
rdbFemale.Checked = false;
rdbMale.Checked = false;
chkCS.Checked = false;
chkJava.Checked = false;
chkPHP.Checked = false;
chkSWIFT.Checked = false;
txtUsername.Focus();
}
}
}
3. Form Quiz
Interface

Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuizTestApp
{
public partial class frmQuiz : Form
{
public frmQuiz()
{
InitializeComponent();
}

private void btnNext_Click(object sender, EventArgs e)


{
frmScore mainForm = new frmScore();
mainForm.Show();
this.Hide();
}
}
}
4. Form Score
Interface

Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuizTestApp
{
public partial class frmScore : Form
{
public frmScore()
{
InitializeComponent();
}

private void btnNext_Click(object sender, EventArgs e)


{
frmQuiz mainForm = new frmQuiz();
mainForm.Show();
this.Hide();
}
}
}

You might also like