Example #1
0
        // fungsi checkin
        public bool insertRsv(String name, String phone, String address, String room, DateTime checkin, DateTime checkout, Int32 deposit)
        {
            MySqlCommand command     = new MySqlCommand();
            String       insertQuery = "INSERT INTO `reservation`(`name`, `phone`, `address`, `room`, `checkin`, `checkout`, `deposit`) VALUES (@name,@phone,@address,@room,@checkin,@checkout,@deposit)";

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

            // @name,@phone,@address,@room,@checkin,@checkout,@deposit
            command.Parameters.Add("@name", MySqlDbType.VarChar).Value      = name;
            command.Parameters.Add("@phone", MySqlDbType.VarChar).Value     = phone;
            command.Parameters.Add("@address", MySqlDbType.VarChar).Value   = address;
            command.Parameters.Add("@room", MySqlDbType.VarChar).Value      = room;
            command.Parameters.Add("@checkin", MySqlDbType.DateTime).Value  = checkin;
            command.Parameters.Add("@checkout", MySqlDbType.DateTime).Value = checkout;
            command.Parameters.Add("@deposit", MySqlDbType.Int32).Value     = deposit;

            conn.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.closeConnection();
                return(true);
            }
            else
            {
                conn.closeConnection();
                return(false);
            }
        }
Example #2
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.CommandText = query;
            command.Connection  = conn.getConnection();

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

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

            // kondisi pada login
            if (table.Rows.Count > 0)
            {
                // tampilkan main form
                this.Hide();
                MainForm mForm = new MainForm();
                mForm.Show();
                ManageReservationForm manresForm = new ManageReservationForm();
                manresForm.Show();
            }
            else
            {
                //
                if (textBoxUsername.Text.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Your Username to Login", "Empty Username", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (textBoxPassword.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", "Wrong Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }