Beispiel #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            ConnectServer sr = new ConnectServer();

            try
            {
                string           qry = "select * from login where Designation='" + comLog.Text.Trim() + "' and UserName='******' and Password='******'";
                MySqlDataAdapter adp = new MySqlDataAdapter(qry, sr.ConPass());
                DataTable        dt  = new DataTable();
                adp.Fill(dt);
                if (dt.Rows.Count == 1)
                {
                    MessageBox.Show("Access Granted..!\n\n Welcome" + " " + txtUser.Text.Trim() + " " + "to the System");
                    this.Hide();
                    Home hom = new Home();
                    hom.Show();
                }
                else
                {
                    MessageBox.Show("Access Denied..\n Please Try Again..!");
                }
                comLog.ResetText();
                txtPass.Clear();
                txtUser.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Oops: Something went wrong with the DB Connection Please try again\n" + ex.Message);
            }
            sr.ConnClose();
        }