private void enterBtn_Click(object sender, EventArgs e) { string log = textBox2.Text; string pass = textBox1.Text; if (string.IsNullOrEmpty(textBox2.Text) || string.IsNullOrEmpty(textBox1.Text)) { MessageBox.Show("Please Fill all the fields"); return; } using (SqlConnection Conn = new SqlConnection(sqlconn)) { if (string.IsNullOrEmpty(textBox2.Text) || string.IsNullOrEmpty(textBox1.Text)) { MessageBox.Show("Please Fill all the fields"); return; } Conn.Open(); String query = String.Format(@"select * from dbo.LOGIN where User_name='{0}' and Password='******'", log, pass); SqlCommand comm = new SqlCommand(query, Conn); SqlDataReader rd = comm.ExecuteReader(); if (!rd.HasRows) { MessageBox.Show("Ivalid Email ID or Password"); return; } rd.Close(); Int32 id = (Int32)comm.ExecuteScalar(); if (id == 1) { ln = "admin"; this.Hide(); FormAdmin a = new FormAdmin(); a.Show(); } else if (id == 0) { ln = "manager"; this.Hide(); FormManager m = new FormManager(); m.Show(); } else { MessageBox.Show("LOGIN FAILED"); } } }
private void backBtn_Click(object sender, EventArgs e) { if (FormLoginAs.ln == "manager") { this.Hide(); FormManager m = new FormManager(); m.Show(); } else { this.Hide(); FormAdmin m = new FormAdmin(); m.Show(); } }
private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text)) { MessageBox.Show("Please Fill All The Fields"); return; } SqlConnection conn = new SqlConnection(sqlconn); conn.Open(); SqlCommand cmd = new SqlCommand("select Password from LOGINS where User_name='Manager' or User_name='Admin'", conn); SqlDataReader reader = cmd.ExecuteReader(); reader.Close(); string pwd = (string)cmd.ExecuteScalar(); if (pwd != textBox1.Text) { MessageBox.Show("Please Enter Correct Current Password"); return; } cmd.CommandText = "update LOGINS set Password='******' where User_name='Manager' or User_name='Admin'"; reader = cmd.ExecuteReader(); if (FormLoginAs.ln == "manager") { this.Hide(); FormManager m = new FormManager(); m.Show(); } else { this.Hide(); FormAdmin a = new FormAdmin(); a.Show(); } }