コード例 #1
0
        private void btnVacant_Click(object sender, EventArgs e)
        {
            VacantRoomsForm vacantRoomsForm = new VacantRoomsForm();

            this.Close();
            vacantRoomsForm.Show();
        }
コード例 #2
0
        private void vacantRoomsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();

            VacantRoomsForm vacantRoomsForm = new VacantRoomsForm();

            vacantRoomsForm.Show();
        }
コード例 #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            using (var db = DatabaseConnection.Connect())
            {
                // To get username and password
                LoginUser loginUser = new LoginUser()
                {
                    Username = txtUsername.Text,
                    Password = txtPassword.Text
                };

                // To execute stored procedure
                var result = db.Query <User>("LoginUser", loginUser, commandType: CommandType.StoredProcedure).FirstOrDefault();

                if (result != null)
                {
                    // If username and password is matched show vacant rooms
                    this.Hide();

                    if (result.Role == "Admin")
                    {
                        AdminHomeForm adminHomeForm = new AdminHomeForm();
                        adminHomeForm.Show();
                    }
                    else
                    {
                        VacantRoomsForm vacantRoomsForm = new VacantRoomsForm();
                        vacantRoomsForm.Show();
                    }
                }
                else
                {
                    // Else show message box
                    MessageBox.Show("Invalid username or password.");
                }
            }
        }
コード例 #4
0
        private void btnCheckIn_Click(object sender, EventArgs e)
        {
            using (var db = DatabaseConnection.Connect())
            {
                // Insert Guest
                Guest guest = new Guest()
                {
                    FirstName     = txtFirstName.Text,
                    LastName      = txtLastName.Text,
                    MiddleName    = txtMiddleName.Text != "" ? txtMiddleName.Text : "",
                    ContactNumber = txtContactNumber.Text,
                    Accompany     = txtAccompany.Text
                };

                db.Query <Guest>("CreateGuest", guest, commandType: CommandType.StoredProcedure);

                // Get Last Inserted Guest
                int guestId = db.QueryFirstOrDefault <int>("GetLastInsertedGuest", commandType: CommandType.StoredProcedure);
                int roomId  = int.Parse(txtRoomId.Text);

                // We can now create Transaction with the Guest Id
                TransactionRecord transaction = new TransactionRecord()
                {
                    CheckInDate  = DateTime.Now,
                    CheckInTime  = DateTime.Now,
                    CheckOutDate = dtpCheckOutDate.Value,
                    CheckOutTime = dtpCheckOutTime.Value,
                    GuestId      = guestId,
                    RoomId       = roomId,
                    Status       = "CheckIn"
                };

                // Insert Transction
                db.Query <TransactionRecord>("CreateTransactionRecord", transaction, commandType: CommandType.StoredProcedure);

                // Update selected room to occupied
                db.Query <TransactionRecord>("UpdateRoomToOccupied", new { roomId = roomId }, commandType: CommandType.StoredProcedure);

                // Get Last Inserted Transaction Record
                int transactionId = db.QueryFirstOrDefault <int>("GetLastInsertedTransactionRecord", commandType: CommandType.StoredProcedure);

                //Insert Payment to add downpayment
                Payment payment = new Payment()
                {
                    DownPayment   = double.Parse(txtDownPayment.Value.ToString()),
                    BasePrice     = 0,
                    TotalPrice    = 0,
                    CashOnHand    = 0,
                    CashChange    = 0,
                    DateOfPayment = DateTime.Now,
                    TimeOfPayment = DateTime.Now,
                    TransactionId = transactionId
                };

                db.Query <Payment>("CreatePayment", payment, commandType: CommandType.StoredProcedure);

                ClearForm();

                this.Close();
                VacantRoomsForm vacantRoomsForm = new VacantRoomsForm();
                vacantRoomsForm.Show();
            }
        }