コード例 #1
0
        //Upon leaving focus of the Room number textbox.
        private void txtRoomNo_Leave(object sender, EventArgs e)
        {
            if (txtRoomNo.Text == "")
            {
                //Informs the user to enter a value in the Room Number field.
                epRoomNo.SetError(this.txtRoomNo, "Please enter a room number");
            }
            else
            {
                epRoomNo.Clear();

                //New instance of UseDatabase class.
                UseDatabase useDb = new UseDatabase("..\\..\\App_Data\\database.accdb");

                //Connect database.
                useDb.ConnectToDatabase();

                //Execute query to autofill room data from the room number provided.
                string queryString = "SELECT GuestName, CheckInDate, NoOfDays, NoOfPeople, TotalDue FROM [CheckIn] WHERE RoomNum = '" + txtRoomNo.Text + "'";

                //Execute query to check for matches in the database.
                OleDbDataReader dbReader = useDb.ExecuteQuery(queryString);

                //If there are rows in the result from the ExecuteQuery then the check was successful meaning there was a match.
                if (dbReader != null && dbReader.HasRows)
                {
                    string          queryString2 = "SELECT RoomType, RoomRate FROM [Room] WHERE RoomNumber = '" + txtRoomNo.Text + "'";
                    OleDbDataReader dbReader2    = useDb.ExecuteQuery(queryString2);

                    //Checks for matches to the room no to get the rest of the info like guest name, room type, checkin date and total payment due.
                    if (dbReader.Read())
                    {
                        txtGuestName.Text = dbReader[0].ToString();
                        txtCheckIn.Text   = dbReader[1].ToString();
                        txtNoDays.Text    = dbReader[2].ToString();
                        txtNoPeople.Text  = dbReader[3].ToString();
                        txtSubTotal.Text  = dbReader[4].ToString();
                    }
                    else
                    {
                        epGuest.SetError(this.txtGuestName, "Guest not checked in");
                    }
                    if (dbReader2.Read())
                    {
                        txtRoomType.Text = dbReader2[0].ToString();
                        txtRoomRate.Text = dbReader2[1].ToString();
                    }
                    else
                    {
                        epRoomNo.SetError(this.txtRoomNo, "No room found for guest name provided");
                    }
                }
                else
                {
                    //Informs the user if the room was not found.
                    epRoomNo.SetError(this.txtRoomNo, "Guest not found");
                }
            }
        }
コード例 #2
0
ファイル: frmReservation.cs プロジェクト: Z3ppellin/OB-RS
        private void tbGuestName_Leave(object sender, EventArgs e)
        {
            if (tbGuestName.Text != "")
            {
                //Clears the error provider for guest name.
                epGuestName.Clear();

                //New instance of UseDatabase class.
                UseDatabase useDb = new UseDatabase("..\\..\\App_Data\\database.accdb");

                //Connect database.
                useDb.ConnectToDatabase();

                //Execute query to autofill room data from the room number provided.
                string queryString = "SELECT GuestName FROM [Guest] WHERE Guestname = '" + tbGuestName.Text + "'";

                //Execute query to check for matches in the database.
                OleDbDataReader dbReader = useDb.ExecuteQuery(queryString);

                //If there are rows in the result from the ExecuteQuery then the check was successful meaning there was a match.
                if (dbReader != null && dbReader.HasRows)
                {
                    epGuestName.Clear();
                }
                else
                {
                    epGuestName.SetError(tbGuestName, "Guest not found");
                }
            }
        }
コード例 #3
0
ファイル: frmReservation.cs プロジェクト: Z3ppellin/OB-RS
        private void tbRoomNum_Leave(object sender, EventArgs e)
        {
            if (tbRoomNum.Text != string.Empty)
            {
                //New instance of the UseDatabase class
                UseDatabase useDb = new UseDatabase("..\\..\\App_Data\\database.accdb");

                //Connect to the database
                useDb.ConnectToDatabase();

                //Query to autofill the rooms data from the room number provided
                string queryString = "SELECT Status,RoomType, RoomRate FROM [Room] WHERE RoomNumber = '" + tbRoomNum.Text + "'";

                //Execute Query to check for matches
                OleDbDataReader dbReader = useDb.ExecuteQuery(queryString);

                //If the query executed it means there was a match
                if (dbReader != null && dbReader.HasRows)
                {
                    if (dbReader.Read())
                    {
                        string roomStatus = dbReader[0].ToString();
                        if (roomStatus == "Available")
                        {
                            tbRoomType.Text = dbReader[1].ToString();
                            tbRoomRate.Text = dbReader[2].ToString();
                            roomRate        = Convert.ToInt32(tbRoomRate.Text);
                            tbSubTotal.Text = "R" + tbRoomRate.Text;
                            subTotal        = Convert.ToInt32(tbNoDays.Text) * roomRate;
                            epStatus.Clear();
                            epGuestName.Clear();
                            epRoomNum.Clear();
                        }
                        else
                        {
                            epStatus.SetError(tbRoomNum, "Room not available");
                        }
                    }
                }
                else
                {
                    epRoomNum.Clear();
                    epRoomNum.SetError(tbRoomNum, "Room number not found");
                }
            }
            else
            {
                epRoomNum.SetError(tbRoomNum, "Please enter a room number");
            }
        }
コード例 #4
0
ファイル: frmCheckIn.cs プロジェクト: Z3ppellin/OB-RS
        private void txtRoomNumber_Leave(object sender, EventArgs e)
        {
            //Checks if the room no field is empty.
            if (txtRoomNumber.Text != "")
            {
                epRoomNo.Clear();

                //New instance of UseDatabase class.
                UseDatabase useDb = new UseDatabase("..\\..\\App_Data\\database.accdb");

                //Connect database.
                useDb.ConnectToDatabase();

                //Execute query to autofill room data from the room number provided.
                string queryString = "SELECT RoomType, RoomRate FROM [Room] WHERE RoomNumber = '" + txtRoomNumber.Text + "'";

                //Execute query to check for matches in the database.
                OleDbDataReader dbReader = useDb.ExecuteQuery(queryString);

                //If there are rows in the result from the ExecuteQuery then the check was successful meaning there was a match.
                if (dbReader != null && dbReader.HasRows)
                {
                    //Checks for matches to the room no to get the room type and rate from the database.
                    if (dbReader.Read())
                    {
                        txtRoomType.Text = dbReader[0].ToString();
                        txtRoomRate.Text = dbReader[1].ToString();
                        roomRate         = Convert.ToInt32(txtRoomRate.Text);
                        txtSubTotal.Text = "R" + txtRoomRate.Text;
                        subTotal         = Convert.ToInt32(txtNoDays.Text) * roomRate;
                    }
                }
                else
                {
                    //Informs the user if the room was not found.
                    epRoomNo.SetError(this.txtRoomNumber, "Room number not found");
                }
            }
            else
            {
                //Asks the user to enter a room no.
                epRoomNo.SetError(this.txtRoomNumber, "Please enter a room number");
            }
        }
コード例 #5
0
        private void btnLogIn_Click(object sender, EventArgs e)
        {
            //Variables.
            string sName     = txtUsername.Text;
            string sPassword = txtPassword.Text;

            //New instance of UseDatabase class.
            UseDatabase useDb = new UseDatabase("..\\..\\App_Data\\database.accdb");

            //Connect database.
            useDb.ConnectToDatabase();

            //Generates a query for the database containing the username and password
            string queryString = "SELECT * FROM [Users] WHERE Username = '******'AND Password = '******';";

            //Execute query to check for matches in the database.
            OleDbDataReader dbReader = useDb.ExecuteQuery(queryString);

            //If there are rows in the result from the ExecuteQuery then the check was successful meaning there was a match.
            if (dbReader != null && dbReader.HasRows)
            {
                //Informs the user that the login was successfull with a warming message.
                this.Hide();
                MessageBox.Show("Welcome " + sName, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                frmMain fM = new frmMain(txtUsername.Text);
                fM.ShowDialog();
            }
            else
            {
                //Informs the user that either the username or password is incorrect.
                MessageBox.Show("Incorrect username or password!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUsername.Clear();
                txtPassword.Clear();
            }
        }
コード例 #6
0
ファイル: frmAdminConfirm.cs プロジェクト: Z3ppellin/OB-RS
        private void button1_Click(object sender, EventArgs e)
        {
            if (tbAdminPassword.Text == "")
            {
                epAdminPass.SetError(this.tbAdminPassword, "Please enter an admin password");
            }
            else
            {
                String sPassword = tbAdminPassword.Text;

                //New instance of UseDatabase class.
                UseDatabase useDb = new UseDatabase(Application.StartupPath + "\\App_Data\\database.accdb");

                //Connect database.
                useDb.ConnectToDatabase();

                string queryString = "SELECT * FROM [Users] WHERE Username = '******' AND Password = '******';";

                //Execute query to check for matches.
                OleDbDataReader dbReader = useDb.ExecuteQuery(queryString);

                //If there are rows in the result from the ExecuteQuery then the check was successful.
                if (dbReader != null && dbReader.HasRows)
                {
                    this.Hide();
                    MessageBox.Show("Success!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    frmForgotPassword FP = new frmForgotPassword();
                    FP.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Incorrect password!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }