Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Visual Studio C# Lab Manual

LAB [02]

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 Lec02
{
public partial class frmLogin : Form
{
public frmLogin()
{
InitializeComponent();
}

private void btnOk_Click(object sender, EventArgs e)


{
if(txtUserName.Text=="admin" && txtPassword.Text=="user" )
{
this.Hide();
SecondForm Form2 = new SecondForm();
Form2.Show();
}
else
{
MessageBox.Show("Incorrect User Name or Password");
txtUserName.Clear();
txtPassword.Clear();
}
}

private void btnCancel_Click(object sender, EventArgs e)


{
Application.Exit();
}
}
}

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 Lec02
{
public partial class SecondForm : Form
{
public SecondForm()
{
InitializeComponent();
}
private void btnAddName_Click(object sender, EventArgs e)
{
string strName;
strName = txtName.Text;
if (strName == "")
{
MessageBox.Show("Please Enter Name..... ");
}
else
{
listBox1.Items.Add(strName);
}

txtName.Clear();
txtName.Focus();

private void SecondForm_Load(object sender, EventArgs e)


{

}
}
}

You might also like