コード例 #1
0
ファイル: FrmTips.cs プロジェクト: stemakwenyu/Vet-System
        private void btnQuit_Click(object sender, EventArgs e)
        {
            FrmDashboard das = new FrmDashboard();

            das.Visible = true;
            this.Close();
        }
コード例 #2
0
ファイル: frmLogin.cs プロジェクト: stemakwenyu/Vet-System
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (txtEmailAdress.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmailAdress.Focus();
            }
            else if (txtPassword.Text == "")
            {
                MessageBox.Show("Ensure all fields are filled", "MESS Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
            }
            else
            {
                try
                {
                    conn   connect = new conn();
                    string query   = "SELECT * FROM officer WHERE Email_Address='" + txtEmailAdress.Text.ToString() + "' AND Passsword='" + txtPassword.Text.ToString() + "' AND Status=1";
                    //open connection
                    if (connect.OpenConnection() == true)
                    {
                        //create command and assign the query and connection from the constructor
                        MySqlCommand    cmd        = new MySqlCommand(query, connect.connection);
                        MySqlDataReader dataReader = cmd.ExecuteReader();

                        //Read the data and store them in the list
                        if (dataReader.Read())
                        {
                            /*MessageBox.Show("Login successful");
                             * Dashboard das = new Dashboard();*/
                            FrmDashboard das = new FrmDashboard();
                            das.Visible = true;
                            this.Hide();
                        }

                        else
                        {
                            txtEmailAdress.Text = "";
                            txtPassword.Text    = "";
                            txtEmailAdress.Focus();
                            MessageBox.Show("password/username mismatch!");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("" + ex);
                }
            }
        }