コード例 #1
0
ファイル: User.cs プロジェクト: hammerj01/Kasilak-PMS
        public void AddNew(User newUser)
        {
            MyConnection newConnection = new MyConnection();
            MySqlCommand comm = new MySqlCommand();
            MySqlConnection conn = new MySqlConnection(newConnection.ConnectionString);

            try
            {
                conn.Open();

                String strQuery = "INSERT INTO tblUser(UserTypeID, Username, Password) VALUES" +
                                  " ('" + newUser.UserTypeID + "','" + newUser.strUsername + "','" + newUser.strPassword + "')";

                comm.Connection = conn;
                comm.CommandText = strQuery;
                comm.ExecuteNonQuery();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "PMIS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            conn.Close();
        }
コード例 #2
0
ファイル: frmLogin.cs プロジェクト: hammerj01/Kasilak-PMS
        private void cmdLogin_Click(object sender, EventArgs e)
        {
            User newUser = new User();
            ParishInformationManagement newMDI = new ParishInformationManagement();

            if (string.IsNullOrEmpty(txtUsername.Text))
            {
                MessageBox.Show("Please specify username.","User Login",MessageBoxButtons.OK,MessageBoxIcon.Information);
                txtUsername.Focus();
                return;
            }

            else if (string.IsNullOrEmpty(txtPassword.Text))
            {
                MessageBox.Show("Please specify password.", "User Login", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPassword.Focus();
                return;
            }

            else if (!newUser.UsernameExist(txtUsername.Text))
            {
                MessageBox.Show("Username or Password does not match.", "User Login", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtUsername.Focus();
                return;
            }

            else if (!newUser.PasswordExist(txtPassword.Text))
            {
                MessageBox.Show("Username or Password does not match.", "User Login", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtUsername.Focus();
                return;
            }
            MessageBox.Show("Successfully log-in");
            newMDI.Show();
            this.Hide();
        }