Sign Up: Using Using Using Using Using Using Using Using Using Namespace
Sign Up: Using Using Using Using Using Using Using Using Using Namespace
Sign Up: Using Using Using Using Using Using Using Using Using Namespace
using using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; System.Data.SqlClient;
namespace project { public partial class signup : Form { SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=project;Integrated Security=True"); public signup() { InitializeComponent(); } private void label1_Click(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; } private void pictureBox1_Click(object sender, EventArgs e) { Close(); /*Form1 obj = new Form1(); obj.Show();*/ } private void button1_Click(object sender, EventArgs e) { } private void button1_Click_1(object sender, EventArgs e) {
int a = 0,b=0; if (textBox1.Text == "") { a = 1; label6.Visible = true; } if (textBox2.Text == "") { a = 1; label7.Visible = true; } if (textBox3.Text == "") { a = 1; label8.Visible = true; } if (textBox4.Text == "") { a = 1; label9.Visible = true; } if (textBox5.Text == "") { a = 1; label10.Visible = true; } if (textBox4.Text != textBox5.Text) { b = 1; label9.Visible = true; label10.Visible = true;
} if (a == 0&&b == 0) { SqlCommand cmd = new SqlCommand("insert into signup(Name,Emp_id,User_name,Password) values(@name,@empid,@user,@pass)", con); cmd.Parameters.Add("@name", SqlDbType.VarChar); cmd.Parameters["@name"].Value = textBox2.Text; cmd.Parameters.Add("@empid", SqlDbType.VarChar); cmd.Parameters["@empid"].Value = textBox1.Text; cmd.Parameters.Add("@user", SqlDbType.VarChar); cmd.Parameters["@user"].Value = textBox3.Text; cmd.Parameters.Add("@pass", SqlDbType.VarChar); cmd.Parameters["@pass"].Value = textBox4.Text; con.Open(); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("add"); } else if(a==1) {
MessageBox.Show("fill red boxes"); // timer1.Start(); } else if (b == 1) { MessageBox.Show("password don't match"); } else { MessageBox.Show("check your form"); } } private void textBox1_TextChanged(object sender, EventArgs e) { /*timer1.Stop(); textBox1.BackColor = Color.White;*/ } private void textBox2_TextChanged(object sender, EventArgs e) { //textBox2.BackColor = Color.White; } private void textBox3_TextChanged(object sender, EventArgs e) { //textBox3.BackColor = Color.White; } private void textBox4_TextChanged(object sender, EventArgs e) { //textBox4.BackColor = Color.White; } private void textBox5_TextChanged(object sender, EventArgs e) { //textBox5.BackColor = Color.White; } private void button3_Click(object sender, EventArgs e) { Form2 obj = new Form2(); obj.Show(); }
} }
COMBO
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; using System.Data.SqlClient; namespace project { public partial class Form2 : Form { SqlConnection con = new SqlConnection("Data Source=HONEY-PC;Initial Catalog=project;Integrated Security=True"); public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("select Emp_id from signup", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { comboBox1.DisplayMember = "Emp_id"; comboBox1.DataSource = dt; } } private void button1_Click(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("select * from signup where Emp_id='"+comboBox1.Text+"'", con); con.Open(); SqlDataReader myReader; myReader = cmd.ExecuteReader(); while (myReader.Read()) {
LOGIN
using using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; System.Data.SqlClient;
namespace project { public partial class Form1 : Form { SqlConnection con = new SqlConnection("Data Source=HONEY-PC;Initial Catalog=project;Integrated Security=True"); public Form1() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = "";
} private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { signup obj = new signup(); obj.Show(); } private void button1_Click(object sender, EventArgs e) { con.Open(); SqlCommand cmd = new SqlCommand("select User_name,Password from signup", con);// where User_name='" + textBox1.Text + "' and Password='" + textBox2.Text + "'", con); SqlDataReader dr = cmd.ExecuteReader(); string userText = textBox1.Text; string passText = textBox2.Text; while (dr.Read()) { if (dr["User_name"].ToString() == userText && dr["Password"].ToString() == passText) { Form2 obj = new Form2(); obj.Show(); } // // else { // //} MessageBox.Show("user name & password donot match");
} dr.Close(); con.Close(); } } }