Introduction:
Address book stores information of your family member or other person. This project contain some forms such as login form .
Address book stores information of your family member or other person. This project contain some forms such as login form .
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AddressBook
{
public partial class LoginForm : Form
{
Thread appThread;
public LoginForm()
{
InitializeComponent();
}
private void loginButton_Click(object sender, EventArgs e)
{
if (unameTextBox.Text == "admin" && passwordTextBox.Text == "password")
{
this.Close();
appThread = new Thread(LaunchAdminApplication);
appThread.SetApartmentState(ApartmentState.STA);
appThread.Start();
}
else
MessageBox.Show("Invalid Credentials", "Login Error!");
}
private void LaunchAdminApplication()
{
Application.Run(new MainForm());
}
}
}
Here "unameTextBox" is the name property of the username textbox and "passwordTextBox" is the property of Password text box . if username and password are right then you can enter into new thread. A message box generated if your username and password are wrong .using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AddressBook
{
public partial class LoginForm : Form
{
Thread appThread;
public LoginForm()
{
InitializeComponent();
}
private void loginButton_Click(object sender, EventArgs e)
{
if (unameTextBox.Text == "admin" && passwordTextBox.Text == "password")
{
this.Close();
appThread = new Thread(LaunchAdminApplication);
appThread.SetApartmentState(ApartmentState.STA);
appThread.Start();
}
else
MessageBox.Show("Invalid Credentials", "Login Error!");
}
private void LaunchAdminApplication()
{
Application.Run(new MainForm());
}
}
}
Tidak ada komentar:
Posting Komentar