LOGIN PAGE CODE
private void button1_Click(object sender, EventArgs e)
{
balusers obj= new balusers();
obj.Username = textBox1.Text;
obj.Password = textBox2.Text;
DataSet myds = obj.logindata();
int i = myds.Tables[0].Rows.Count;
if (i > 0)
{
this.Hide();
master obj1 = new master();
obj1.Show();
}
else
{
MessageBox.Show("Username or Password invalid ");
}
BUSINESS ACCESS LAYER CODE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace infotech
{
class balusers
{
string username, password;
public string Password
{
get { return password; }
set { password = value; }
}
public string Username
{
get { return username; }
set { username = value; }
}
public DataSet logindata()
{
return dalusers.login(username,password);
}
}
}
DATA ACCESS LAYER CODE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace infotech
{
class dalusers
{
public static DataSet login(string username,string password)
{
SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["connec"]);
SqlDataAdapter da = new SqlDataAdapter("splogin",cn);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.Add("@uname", username);
da.SelectCommand.Parameters.Add("@pwd", password);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
}
}
STORED PROCEDURE
CREATE procedure splogin
(@uname varchar(50),@pwd varchar(50))
as
begin
select * from login where username=@uname and password=@pwd
end
MASTER PAGE
MASTER PAGE CODE
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace infotech
{
public partial class master : Form
{
public master()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
login obj = new login();
obj.Close();
this.BackgroundImage = Image.FromFile(@"c:\documents and settings\pappi\my documents\visual studio 2010\Projects\infotech\infotech\image\1.jpg");
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
}
}