Exemplo n.º 1
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (CheckValid() && !addNew)
         {
             Receptionist r = new Receptionist()
             {
                 StaffID   = txtReceptID.Text,
                 FirstName = txtFirstname.Text,
                 LastName  = txtLastname.Text,
                 Address   = txtAdress.Text,
                 Country   = cbCountry.Text,
                 Email     = txtEmail.Text,
                 Phone     = txtPhone.Text,
                 Password  = txtPass.Text,
                 Username  = txtUsername.Text,
                 Status    = cbStatus.Text
             };
             if (ManagerDAL.UpdateRecept(r))
             {
                 ManagerDAL.AddNewLog(new Log()
                 {
                     StaffID = StaffID, ActionTime = DateTime.Now, Main = "Update Receptionist: " + txtReceptID.Text
                 });
                 BindingStatus = false;
                 LoadData();
                 MessageBox.Show("Update successful!");
             }
             else
             {
                 if (cbStatus.SelectedIndex == 1)
                 {
                     cbStatus.SelectedIndex = 0;
                 }
                 MessageBox.Show("Update failed!");
             }
         }
         else
         {
             if (cbStatus.SelectedIndex == 1)
             {
                 cbStatus.SelectedIndex = 0;
             }
             MessageBox.Show("Invalid to Update!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (CheckValid() && addNew)
         {
             Customer re = new Customer()
             {
                 FirstName = txtFirstname.Text,
                 LastName  = txtLastname.Text,
                 Address   = txtAdress.Text,
                 Country   = cbCountry.SelectedItem.ToString(),
                 Email     = txtEmail.Text,
                 Phone     = txtPhone.Text,
                 RegisTime = DateTime.Now,
                 StaffID   = StaffID,
             };
             if (ManagerDAL.AddNewCustomer(re))
             {
                 ManagerDAL.AddNewLog(new Log()
                 {
                     StaffID = StaffID, ActionTime = DateTime.Now, Main = "Add new Customer: " + txtCusID.Text
                 });
                 MessageBox.Show("Add successful!");
                 BindingStatus = false;
                 LoadData();
                 addNew = false;
             }
             else
             {
                 MessageBox.Show("Add failed!");
             }
         }
         else
         {
             MessageBox.Show("Invalid to Add!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 3
0
        private void AddNewBooking()
        {
            try
            {
                DateTime TimeofNow = DateTime.Now;
                Booking  rs        = AddBooking(TimeofNow);

                if (rs != null)
                {
                    //add bang Payment
                    if (AddPayment(TimeofNow, rs))
                    {
                        MessageBox.Show("Booking successful!");
                        ManagerDAL.AddNewLog(new Log()
                        {
                            StaffID    = StaffID,
                            ActionTime = DateTime.Now,
                            Main       = "Booking the room: " + CurrentRoom.RoomNumber.ToString() + " to: " + rs
                        });

                        this.Hide();
                        // MessageBox.Show(rs.BookingID);
                        Thread t = new Thread(new ThreadStart(() => ShowForm(rs.BookingID)));
                        t.Start();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Add Payment Failed!");
                    }
                }
                else
                {
                    MessageBox.Show("Booking failed!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void btnCancelBooking_Click(object sender, EventArgs e)
 {
     try
     {
         var confirmResult = MessageBox.Show("Are you sure to cancel this booking?", "Confirm booking cancel",
                                             MessageBoxButtons.YesNo);
         if (confirmResult == DialogResult.Yes)
         {
             DateTime     ThisTime = DateTime.Now;
             Cancellation c        = new Cancellation()
             {
                 CancelTime = ThisTime,
                 BookingID  = txtBookingId.Text
             };
             bool rs1 = ManagerDAL.AddNewCancel(c);
             //add room_cancel & update payment cancelled + paytime
             bool rs2 = ManagerDAL.AddNewRoomCancel(CurrentRoom.RoomNumber);
             bool rs3 = ManagerDAL.UpdatePayment(txtBookingId.Text, ThisTime, true);
             if (rs1 && rs2 && rs3)
             {
                 ManagerDAL.UpdateRoomStatus(CurrentRoom.RoomNumber, "Available");
                 ManagerDAL.AddNewLog(new Log()
                 {
                     StaffID = StaffID, ActionTime = DateTime.Now, Main = "Cancel Booking Id: " + txtBookingId.Text
                 });
                 MessageBox.Show("Cancel process successful!");
                 GoBackToMain();
             }
             else
             {
                 MessageBox.Show("Cancel process failed!");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void btnEdit_Click(object sender, EventArgs e)
 {
     try
     {
         if (!CheckValid())
         {
             Room r = new Room()
             {
                 RoomNumber    = int.Parse(txtIDNumber.Text),
                 MaxPerson     = int.Parse(txtMaxPerson.Text),
                 PricePerNight = float.Parse(txtPricePer.Text),
                 RoomType      = cbType.Text,
                 Status        = cbStatus.Text
             };
             if (ManagerDAL.UpdateRoom(r))
             {
                 ManagerDAL.AddNewLog(new Log()
                 {
                     StaffID = StaffID, ActionTime = DateTime.Now, Main = "Edit Room: " + CurrentRoom.RoomNumber + " Info"
                 });
                 MessageBox.Show("Update Room successful!");
             }
             else
             {
                 MessageBox.Show("Update Room failed!");
             }
             GoBackToMain();
         }
         else
         {
             MessageBox.Show("Invalid to Update!");
         }
     }catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }