private void signin_btn_Click_1(object sender, EventArgs e) { if (email_txt2.Text == "admin" && pass_txt2.Text == "admin123") { admindashboard admindb = new admindashboard(); admindb.Show(); } else { //code for datastoring and validation cnn.Open(); cmd.CommandText = ("select * from app_users where email='" + email_txt2.Text + "'and password='******'"); cmd.Connection = cnn; SqlDataReader rd = cmd.ExecuteReader(); if (rd.HasRows) { userdashboard userdb = new userdashboard(); userdb.Show(); LoginInfo.email = email_txt2.Text; //MessageBox.Show(LoginInfo.email); } else { msgrtn = "YOU ARE NOT REGISTERED \n PLEASE SIGNIN"; messagebox msgbox = new messagebox(); msgbox.labelmsg(msgrtn); msgbox.Show(); } rd.Close(); cnn.Close(); } }
//login button code private void button1_Click(object sender, EventArgs e) { My_DB db = new My_DB(); MySqlDataAdapter adapter = new MySqlDataAdapter(); DataTable table = new DataTable(); MySqlCommand command = new MySqlCommand("SELECT * FROM `student` WHERE `reg_no`=@reg_no AND `password`=@password", db.getConnection); if (!(textBox1.Text.Trim() == "") && !(textBox2.Text.Trim() == "")) { command.Parameters.Add("@reg_no", MySqlDbType.VarChar).Value = textBox1.Text; command.Parameters.Add("@password", MySqlDbType.VarChar).Value = textBox2.Text; adapter.SelectCommand = command; adapter.Fill(table); if (table.Rows.Count > 0) { if (table.Rows[0][10].ToString() == "0") { session1 = table.Rows[0][1].ToString(); session2 = table.Rows[0][2].ToString(); reg = table.Rows[0][0].ToString(); this.Close(); admindashboard admin = new admindashboard(session1, session2, reg); admin.Show(); } if (table.Rows[0][10].ToString() == "1") { reg = table.Rows[0][0].ToString(); this.Close(); userdashboard user = new userdashboard(reg); user.Show(); } } else { MessageBox.Show("Invalid User..! Please Check Your Register No & Password"); } } else { if (textBox1.Text.Trim() == "") { MessageBox.Show("Please Enter Register Number"); } else { MessageBox.Show("Please Enter Password"); } } }