private void btn_lgn_Click_3(object sender, EventArgs e) { if (txt_user.Text != "" && txt_pswd.Text != "") { string username = txt_user.Text; DataBase_connector dc = new DataBase_connector(); string add = "SELECT * FROM sim_registaration.user where UserName='******';"; DataTable dt = dc.read(add); if (dt.Rows.Count != 0) { foreach (DataRow row in dt.Rows) { Userclass u1 = new Userclass(); u1.password = row[2].ToString(); u1.job = row[10].ToString(); if (u1.password == txt_pswd.Text) { if (u1.job == "Admin") { Form2 f2 = new Form2(); f2.menuStripadmin.Visible = true; f2.label7.Text = "Admin"; this.Hide(); f2.ShowDialog(); this.Show(); } else { Form2 f2 = new Form2(); f2.menuStrip2.Visible = true; f2.label7.Text = "employee"; this.Hide(); f2.ShowDialog(); this.Show(); } } else { MessageBox.Show(" passsword incorrect"); } } } else { MessageBox.Show("wrong user name"); } } else { MessageBox.Show("Empty User name or Password"); } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "" && textBox6.Text != "" && textBox7.Text != "" && textBox8.Text != "" && textBox9.Text != "") { if (textBox7.Text == textBox8.Text) { //pass user input to user class Userclass u1 = new Userclass(); u1.F_name = textBox1.Text; u1.L_name = textBox2.Text; u1.address = textBox3.Text; u1.nic = textBox4.Text; u1.contact = textBox5.Text; u1.u_name = textBox6.Text; u1.password = textBox7.Text; u1.c_question = comboBox1.Text; u1.c_answer = textBox9.Text; //pass data to database string add = "INSERT INTO `sim_registaration`.`user` (`UserName`, `Password`, `F_name`, `L_name`, `address`, `nic_num`, `contact_num`, `confirm_qustn`, `confirm_anwr`) VALUES('" + u1.u_name + "', '" + u1.password + "', '" + u1.F_name + "', '" + u1.L_name + "', '" + u1.address + "', '" + u1.nic + "', '" + u1.contact + "', '" + u1.c_question + "', '" + u1.c_answer + "');"; DataBase_connector db1 = new DataBase_connector(); db1.datainput(add); MessageBox.Show("You have been successfuly"); // data clear textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = ""; comboBox1.Text = "Select"; } else { MessageBox.Show("not match password please recheck"); } } else { MessageBox.Show("Fill all fields"); } }