private void btn_login_Click(object sender, EventArgs e)
        {
            connection = new MySqlConnection(ConnectionString);

            if (txt_uname.Text == "" || txt_pword.Text == "")
            {
                MessageBox.Show("Invalid Username or Password");
            }
            try
            {
                connection.Open();
                MySqlCommand cmd = new MySqlCommand("SELECT uname, pword  From users Where uname = '" + txt_uname.Text + "' And pword ='" + txt_pword.Text + "'", connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                adapter.Fill(ds);
                cmd.ExecuteNonQuery();
                connection.Close();

                int count = ds.Tables[0].Rows.Count;
         
              
                if (count == 1)
                {
                    //MessageBox.Show("Login Successfully!");

                    MainForm main = new MainForm();
                    main.FormClosed += new FormClosedEventHandler(mainformclosed);
                    main.Show();

                    this.Hide();
                }

                else
                {
                    MessageBox.Show("Invalid Username or Password");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btn_login_Click(object sender, EventArgs e)
        {
            connection = new MySqlConnection(ConnectionString);

            try
            {
                connection.Open();
                MySqlCommand cmd = new MySqlCommand("SELECT uname, pword From users Where uname = '" + txt_uname.Text + "' AND  pword = '" + txt_pword.Text + "' and status = 'Active'", connection);
                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                adapter.Fill(ds);
                cmd.ExecuteNonQuery();
                connection.Close();

                int count = ds.Tables[0].Rows.Count;

                if (count == 1)
                {                   
                    MainForm main = new MainForm();
                    main.FormClosed += new FormClosedEventHandler(mainformclosed);
                    main.Show();

                    this.Hide();                
                }
               
                else
                {
                    btn_cancel.PerformClick();
                    MetroMessageBox.Show(this, "Invalid Username or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);                   
                }
            }      
                catch (Exception ex)
                {
                    MetroMessageBox.Show(this, ex.Message);
                }
            }