private bool Validate_login(string user, string pass) { //string myIP = Dns.GetHostByName(hostName).AddressList[0].ToString(); MySqlConnection con = new MySqlConnection(MyConnectionString); con.Open(); MySqlCommand cmd = con.CreateCommand(); cmd.CommandText = "select * from MASTER_USER where UID=@user and SALT=@pass"; cmd.Parameters.AddWithValue("@user", user); cmd.Parameters.AddWithValue("@pass", pass); cmd.Connection = con; MySqlDataReader dt = cmd.ExecuteReader(); if (dt.Read()) { FrmHome home = new FrmHome(); this.LbID.Text = dt[1].ToString(); con.Close(); return(true); } else { con.Close(); return(false); } }
private void BtnSubmit_Click(object sender, EventArgs e) { if (TxtUname.Text == "" || TxtPass.Text == "") { string Pesan = "Input data must be complete. Invalid input data !"; string judul = "Developer System WijayaSoft"; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show(Pesan, judul, buttons, MessageBoxIcon.Warning); } else { try { string user = TxtUname.Text; string pass = TxtPass.Text; FrmHome FrmHome1 = new FrmHome(); if (user == "" || pass == "") { MessageBox.Show("Empty Field Detected ! Please fill up all the fields"); return; } bool r = Validate_login(user, hc.PassHash(pass)); if (r == true) { MessageBox.Show("Correct Login Credentials"); Clear(); this.Hide(); FrmHome1.Show(); UpdateLogin(); } else { MessageBox.Show("Incorrect Login Credentials"); Clear(); } } catch (Exception err) { string Pesan = "Error when to try Read Data. Please Contact Developer." + Environment.NewLine + Environment.NewLine + err.ToString(); string judul = "Developer System WijayaSoft - Error Message"; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show(Pesan, judul, buttons, MessageBoxIcon.Error); } } }