예제 #1
0
        public void TestUpdate()
        {
            //Arrange
            EscapeRoomCtr esrCtr = new EscapeRoomCtr();
            EmployeeCtr   empCtr = new EmployeeCtr();
            EscapeRoom    Er     = new EscapeRoom()
            {
                Description  = "You know I Know I Still got it",
                MaxClearTime = 90,
                CleanTime    = 30,
                Name         = "The best",
                Price        = 300,
                Rating       = 5,
                Emp          = empCtr.Get(2)
            };

            //Act
            esrCtr.CreateEscapeRoom(Er.Name, Er.Description, Er.MaxClearTime, Er.CleanTime, Er.Price, Er.Rating, Er.Emp.EmployeeID, Er.Image);
            EscapeRoom TestEr = esrCtr.GetForOwner(esrCtr.GetAllForOwner().Count);

            esrCtr.UpdateEscapeRoom("The best", "I am the best", 200, 20, 500, 5, Er.Emp.EmployeeID, TestEr.EscapeRoomID, TestEr.Image);
            TestEr = esrCtr.GetForOwner(esrCtr.GetAllForOwner().Count);

            //Assert
            Assert.AreEqual(Er.Name, TestEr.Name);
            Assert.AreNotEqual(Er.Description, TestEr.Description);
        }
예제 #2
0
        public void TestMethod1( )
        {
            //Arrange
            BookingCtr    bc       = new BookingCtr();
            CustomerCtr   cc       = new CustomerCtr();
            EscapeRoomCtr esrCtr   = new EscapeRoomCtr();
            EmployeeCtr   empCtr   = new EmployeeCtr();
            EscapeRoom    Er       = esrCtr.GetForOwner(2);
            Customer      cus      = cc.Get("Anorak");
            Employee      em       = empCtr.Get(1);
            TimeSpan      bookTime = new TimeSpan(16, 00, 00);
            Booking       book     = new Booking()
            {
                AmountOfPeople = 10,
                BookingTime    = bookTime,
                Cus            = cus,
                Date           = DateTime.Now.AddDays(7.0).Date,
                Emp            = em,
                Er             = Er
            };

            //Act
            bc.Create(book.Emp, book.Cus, book.Er, book.BookingTime, book.AmountOfPeople, book.Date);
            Booking TestBook = bc.Get(cus, Er, book.Date);

            bc.Update(book.Cus, book.Er, book.Date, book.Emp, 100, book.BookingTime, TestBook.Id);
            TestBook = bc.Get(cus, Er, book.Date);

            //Assert
            Assert.AreEqual(book.Er.Name, TestBook.Er.Name);
            Assert.AreNotEqual(book.AmountOfPeople, TestBook.AmountOfPeople);

            bc.Delete(cus, Er, book.Date, em, TestBook.AmountOfPeople, TestBook.BookingTime);
        }
예제 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            EscapeRoomCtr erc = new EscapeRoomCtr();
            int           num = int.Parse(txtId.Text);

            label1.Text = erc.GetForOwner(num).Name;
        }
예제 #4
0
 /// <summary>
 /// Opens MainMenu and runs LoadDataGridView()
 /// </summary>
 public MainMenu()
 {
     InitializeComponent();
     bc  = new BookingCtr();
     erc = new EscapeRoomCtr();
     LoadDataGridView();
 }
예제 #5
0
        private void Button1_Click(object sender, EventArgs e)
        {
            EscapeRoomCtr erc = new EscapeRoomCtr();

            foreach (EscapeRoom er in erc.GetAllForOwner())
            {
                listBox1.Items.Add(er.Name);
            }
        }
예제 #6
0
 /// <summary>
 /// Opens Update_Room and runs FillTextBoxEscapeRoom(ER), FillLabelsEmployee(ER.Emp) and cobEmployeeLoad()
 /// </summary>
 /// <param name="esr"></param>
 public Update_Room(EscapeRoom esr)
 {
     InitializeComponent();
     EmpCtr = new EmployeeCtr();
     ERctr  = new EscapeRoomCtr();
     ER     = esr;
     FillTextBoxEscapeRoom(ER);
     FillLabelsEmployee(ER.Emp);
     cobEmployeeLoad();
 }
예제 #7
0
 /// <summary>
 /// Opens "CreateBooking" and initialize the fields
 /// </summary>
 public CreateBooking()
 {
     InitializeComponent();
     Cusctr      = new CustomerCtr();
     ERCtr       = new EscapeRoomCtr();
     BookCtr     = new BookingCtr();
     EmpCtr      = new EmployeeCtr();
     escapeRooms = new List <EscapeRoom>();
     CreateBooking_Load();
     calBookTime.MinDate = DateTime.Now.Date;
 }
예제 #8
0
        /// <summary>
        /// Checks for empty textfields and if none, then it calls "CreateEscapeRoom", "EmptyText" and "UpdateEscapeRoomList"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCreateEscapeRoom_Click(object sender, EventArgs e)
        {
            EscapeRoomCtr esC = new EscapeRoomCtr();

            if (txtName.Text.Trim().Equals(""))
            {
                lblErrorName.Visible = true;
                lblErrorName.Text    = "Mangler input";
            }
            else if (txbDescription.Text.Trim().Equals(""))
            {
                lblErrorDesciption.Visible = true;
                lblErrorDesciption.Text    = "Mangler input";
            }
            else if (txtMaxClearTime.Text.Trim().Equals(""))
            {
                lblErrorMaxClearTime.Visible = true;
                lblErrorMaxClearTime.Text    = "Mangler input";
            }
            else if (txtCleanTime.Text.Trim().Equals(""))
            {
                lblErrorCleanTime.Visible = true;
                lblErrorCleanTime.Text    = "Mangler input";
            }
            else if (txtPrice.Text.Trim().Equals(""))
            {
                lblErrorPrice.Visible = true;
                lblErrorPrice.Text    = "Mangler input";
            }
            else if (txtEmployeeID.Text.Trim().Equals(""))
            {
                lblErrorEmployee.Visible = true;
                lblErrorEmployee.Text    = "Mangler input";
            }
            else if (pbEscaperoom.Image == null)
            {
                lblErrorImage.Visible = true;
            }
            else
            {
                decimal MaxC   = decimal.Parse(txtMaxClearTime.Text);
                decimal ClTi   = decimal.Parse(txtCleanTime.Text);
                decimal Pri    = decimal.Parse(txtPrice.Text);
                decimal rating = 0;
                int     Emp    = int.Parse(txtEmployeeID.Text);
                byte[]  img    = ConvertImgToBinary(pbEscaperoom.Image);
                esC.CreateEscapeRoom(txtName.Text, txbDescription.Text, MaxC, ClTi, Pri, rating, Emp, img);
                EmptyText();
                UpdateEscapeRoomList();
            }
        }
예제 #9
0
        /// <summary>
        /// Fills combobox with avalible times
        /// </summary>
        private void LoadCBBookingTime()
        {
            EscapeRoomCtr erCtr = new EscapeRoomCtr();

            bookingTimes = new List <TimeSpan>();
            bookingTimes = erCtr.FreeTimes(book.Er.EscapeRoomID, book.Date);
            cbBookingTime.Items.Clear();

            foreach (TimeSpan ts in bookingTimes)
            {
                cbBookingTime.Items.Add(ts);
            }
            cbBookingTime.ResetText();
        }
예제 #10
0
        /// <summary>
        /// Fills combobox with Ecaperooms
        /// </summary>
        private void LoadCBEscapeRoom()
        {
            EscapeRoomCtr erCtr = new EscapeRoomCtr();

            escapeRooms = new List <EscapeRoom>();
            escapeRooms = erCtr.GetAllForOwner();
            cbEscaperoom.Items.Clear();

            foreach (EscapeRoom er in escapeRooms)
            {
                cbEscaperoom.Items.Add(er.Name);
            }
            cbEscaperoom.SelectedItem = book.Er.Name;
        }
예제 #11
0
        /// <summary>
        /// Delete botton for escaperoom, shows a message box with a yes/no, if yes then calls erctr.Delete, last it calls "UpdateEscapeRoomList()"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteEscapeRoom_Click(object sender, EventArgs e)
        {
            EscapeRoomCtr erctr = new EscapeRoomCtr();
            DialogResult  result;

            result = MessageBox.Show("Du er ved at slette " + er.Name + ".  er du sikker", "slet Escaperoom", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                erctr.Delete(er.EscapeRoomID);
            }

            UpdateEscapeRoomList();
        }
예제 #12
0
        public void TestBookRoomOwner()
        {
            //Arrange
            BookingCtr    bc  = new BookingCtr();
            CustomerCtr   cc  = new CustomerCtr();
            EscapeRoomCtr ec  = new EscapeRoomCtr();
            EmployeeCtr   emc = new EmployeeCtr();

            MAPMAClient.Model.Customer   cus = cc.Get("Anorak");
            MAPMAClient.Model.EscapeRoom er  = ec.GetForOwner(2);
            MAPMAClient.Model.Employee   em  = emc.Get(1);
            MAPMAClient.Model.Booking    hostBook;
            MAPMAClient.Model.Booking    book = new MAPMAClient.Model.Booking()
            {
                AmountOfPeople = 7,
                BookingTime    = DateTime.Now.TimeOfDay,
                Cus            = cus,
                Date           = DateTime.Now.AddDays(7.0).Date,
                Emp            = em,
                Er             = er
            };
            MAPMAClient.Model.Booking bookWithoutTime = new MAPMAClient.Model.Booking()
            {
                AmountOfPeople = 7,
                Cus            = cus,
                Date           = DateTime.Now.AddDays(7.0).Date,
                Emp            = em,
                Er             = er
            };


            ////Act
            bc.Create(book.Emp, book.Cus, book.Er, book.BookingTime, book.AmountOfPeople, book.Date);
            hostBook = bc.Get(cus, er, book.Date);

            ////Assert
            Assert.AreEqual(bookWithoutTime.Date, hostBook.Date);
            Assert.AreEqual(bookWithoutTime.Emp.EmployeeID, hostBook.Emp.EmployeeID);
            Assert.AreEqual(bookWithoutTime.Cus.Username, hostBook.Cus.Username);

            bc.Delete(cus, er, book.Date, book.Emp, book.AmountOfPeople, book.BookingTime);
        }
예제 #13
0
        /// <summary>
        /// Updates the dataGridView so new escaperooms will be insertet
        /// </summary>
        private void UpdateEscapeRoomList( )
        {
            EscapeRoomCtr esc = new EscapeRoomCtr();
            DataTable     dt  = new DataTable();
            BindingSource bs  = new BindingSource();

            escapeRooms = esc.GetAllForOwner();

            dt.Columns.Add("Escaperoom", typeof(string));
            dt.Columns.Add("Pris", typeof(decimal));
            dt.Columns.Add("Medarbejder", typeof(string));
            dt.Columns.Add("Max Gennemførsels tid", typeof(decimal));
            dt.Columns.Add("Klargøringstid", typeof(decimal));
            dt.Columns.Add("id", typeof(int));

            foreach (var EscapeRoom in escapeRooms)
            {
                dt.Rows.Add(EscapeRoom.Name, EscapeRoom.Price, EscapeRoom.Emp.FirstName + " " + EscapeRoom.Emp.LastName, EscapeRoom.MaxClearTime, EscapeRoom.CleanTime, EscapeRoom.EscapeRoomID);
            }

            bs.DataSource                       = dt;
            dataGridView1.DataSource            = bs;
            dataGridView1.Columns["id"].Visible = false;
        }