Esempio n. 1
0
        //function to add new reservation
        public bool addReserv(int roomNum, int clientId, DateTime dtIn, DateTime dtOut)
        {
            MySqlCommand command  = new MySqlCommand();
            string       addQuery = "INSERT INTO `reservation`(`RoomNo`, `ClientID`, `DateIN`, `DateOUT`) VALUES (@rn,@cid,@dtIN,@dtOUT)";

            //@rn,@cid,@dtIN,@dtOUT
            command.CommandText = addQuery;
            command.Connection  = conn.GetConnection();
            command.Parameters.Add("@rn", MySqlDbType.Int32).Value   = roomNum;
            command.Parameters.Add("@cid", MySqlDbType.Int32).Value  = clientId;
            command.Parameters.Add("@dtIN", MySqlDbType.Date).Value  = dtIn;
            command.Parameters.Add("@dtOUT", MySqlDbType.Date).Value = dtOut;

            conn.OpenConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.CloseConnection();
                return(true);
            }
            else
            {
                conn.CloseConnection();
                return(false);
            }
        }
        //function to add new clients
        public bool addClient(string fName, string lName, string phoneNum, string country)
        {
            MySqlCommand command  = new MySqlCommand();
            string       addQuery = "INSERT INTO `clients`(`first_name`, `last_name`, `phone`, `country`) VALUES (@fname,@lname,@pNum,@cnt)";


            command.CommandText = addQuery;
            command.Connection  = conn.GetConnection();
            command.Parameters.Add("@fname", MySqlDbType.VarChar).Value = fName;
            command.Parameters.Add("@lname", MySqlDbType.VarChar).Value = lName;
            command.Parameters.Add("@pNum", MySqlDbType.VarChar).Value  = phoneNum;
            command.Parameters.Add("@cnt", MySqlDbType.VarChar).Value   = country;

            conn.OpenConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                conn.CloseConnection();
                return(true);
            }
            else
            {
                conn.CloseConnection();
                return(false);
            }
        }
Esempio n. 3
0
        //function to get the list of room type

        public DataTable getRoomType()
        {
            MySqlCommand     command = new MySqlCommand("SELECT * FROM `rooms_category`", conn.GetConnection());
            DataTable        table   = new DataTable();
            MySqlDataAdapter adapter = new MySqlDataAdapter();

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

            return(table);
        }
Esempio n. 4
0
        private void Loginbutton_Click_1(object sender, EventArgs e)
        {
            CONNECT          conn    = new CONNECT();                                                        //our connection
            DataTable        table   = new DataTable();                                                      //creates our table in the dataset
            MySqlDataAdapter adapter = new MySqlDataAdapter();                                               //creates a link between the datasource and the dataset
            MySqlCommand     command = new MySqlCommand();                                                   //executes our sql queries etc.
            string           query   = "SELECT * FROM `users` WHERE `username`=@usn AND `password` = @pass"; //@pass and @usn are placeholders

            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = textBoxUsername.Text;               //it takes the input from the user and replace its respective placeholder of its type
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = textBoxPassword.Text;

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

            adapter.SelectCommand = command; //the adapter here uses the selectcommand to retrieve data specified in the datasource i.e the database
            adapter.Fill(table);             // if the value retrieved matches the one at the data source then it fills the table data in the dataset if the table hasn't been created then it creates one.

            //if the username and password exists
            if (table.Rows.Count > 0) //if the no of rows in the table in the dataset then execute the content within.
            {
                //show the main form
                this.Hide();
                Main_Form mForm = new Main_Form();
                mForm.Show();
            }
            else if (textBoxUsername.Text.Trim().Equals(""))
            {
                MessageBox.Show("Enter a valid username", "Username", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (textBoxPassword.Text.Trim().Equals(""))
            {
                MessageBox.Show("Enter a valid password", "Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("Username or Password does not exist", "Incorrect data", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }