コード例 #1
0
        public bool insertClient(String fName, String lName, String phone, String country)
        {
            MySqlCommand command     = new MySqlCommand();
            String       insertQuery = "INSERT INTO `clients`(`fName`, `lName`, `phone`, `country`) VALUES (@fn,@ln,@phn,@cnt)";

            command.CommandText = insertQuery;
            command.Connection  = conn.getConnection();

            command.Parameters.Add("@fn", MySqlDbType.VarChar).Value  = fName;
            command.Parameters.Add("@ln", MySqlDbType.VarChar).Value  = lName;
            command.Parameters.Add("@phn", MySqlDbType.VarChar).Value = phone;
            command.Parameters.Add("@cnt", MySqlDbType.VarChar).Value = country;

            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.closeConnection();
                return(true);
            }
            else
            {
                conn.closeConnection();
                return(false);
            }
        }
コード例 #2
0
        public bool insertClient(String fname, String lname, String phone, String country)
        {
            MySqlCommand command     = new MySqlCommand();
            String       insertQuery = "INSERT INTO clients(first_name, last_name, phone, country) VALUES (@fnm, @lnm, @phn, @cnt);";

            //@fnm, @lnm, @phn, @cnt
            command.Parameters.Add("@fnm", MySqlDbType.VarChar).Value = fname;
            command.Parameters.Add("@lnm", MySqlDbType.VarChar).Value = lname;
            command.Parameters.Add("@phn", MySqlDbType.VarChar).Value = phone;
            command.Parameters.Add("@cnt", MySqlDbType.VarChar).Value = country;

            command.CommandText = insertQuery;
            command.Connection  = conn.getConnection();

            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.closeConnection();
                return(true);
            }
            else
            {
                conn.closeConnection();
                return(false);
            }
        }
コード例 #3
0
        public DataTable getAllReserve()
        {
            MySqlCommand     command = new MySqlCommand("SELECT * FROM `reservations`", conn.getConnection());
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            DataTable        table   = new DataTable();

            adapter.SelectCommand = command;
            adapter.Fill(table);

            return(table);
        }
コード例 #4
0
        public DataTable roomTypeList()
        {
            MySqlCommand     command = new MySqlCommand("SELECT * FROM rooms_category;", conn.getConnection());
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            DataTable        table   = new DataTable();

            adapter.SelectCommand = command;
            adapter.Fill(table);

            return(table);
        }
コード例 #5
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            CONNECT          conn    = new CONNECT();
            DataTable        table   = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand();
            String           query   = "SELECT * FROM users WHERE username=@usn AND password=@pass;";

            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = textBoxUsername.Text;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = textBoxPassword.Text;
            command.CommandText = query;
            command.Connection  = conn.getConnection();


            adapter.SelectCommand = command;
            adapter.Fill(table);

            if (table.Rows.Count > 0)
            {
                MessageBox.Show(textBoxUsername.Text.ToUpper() + " has logged in!");
                this.Hide();
                Main_Form main_Form = new Main_Form();
                main_Form.Show();
            }
            else
            {
                if (textBoxUsername.Text.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Username", "Empty Username", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else if (textBoxPassword.Text.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Password", "Empty Password", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    MessageBox.Show("Wrong Data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #6
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            CONNECT          conn    = new CONNECT();
            DataTable        table   = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand();
            String           query   = "SELECT * FROM `user` WHERE `username`=@usn AND `password`=@pass";

            command.CommandText = query;
            command.Connection  = conn.getConnection();

            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = txtUsername.Text;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = txtPassword.Text;

            adapter.SelectCommand = command;
            adapter.Fill(table);

            if (table.Rows.Count > 0)
            {
                this.Hide();
                Main_Form mform = new Main_Form();
                mform.Show();
            }
            else
            {
                if (txtUsername.Text.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Your Username to Login", "Empty Username!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (txtPassword.Text.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Your Password to Login", "Empty Password!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("This Username or Password doesn't Exists.", "Invalid Data!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }