Пример #1
0
        public IHttpActionResult Post([FromBody] Reservation_DTO reservation_DTO)
        {
            IHttpActionResult result;

            if (reservation_DTO.CustomerID < 0)
            {
                result = Content(HttpStatusCode.Conflict, "The CustomerID is not valid.");
            }
            else if (reservation_DTO.EmployeeID < 0)
            {
                result = Content(HttpStatusCode.Conflict, "The EmployeeID is not valid.");
            }
            else if (reservation_DTO.TreatmentID < 0)
            {
                result = Content(HttpStatusCode.Conflict, "The Treatment is not valid.");
            }
            else if (reservation_DTO.StartTime.ToLocalTime().CompareTo(DateTime.Now) < 0)
            {
                result = Content(HttpStatusCode.Conflict, "The start-time is not valid.");
            }
            else
            {
                result = _submitToDatabase(reservation_DTO);
            }

            return(result);
        }
Пример #2
0
        private IHttpActionResult _submitToDatabase(Reservation_DTO reservation_DTO)
        {
            IHttpActionResult result;

            try
            {
                Treatment   treatmentToUse   = _dbTreatment.GetTreatmentByID(reservation_DTO.TreatmentID);
                Reservation reservationToAdd = new Reservation(treatmentToUse, reservation_DTO.CustomerID, reservation_DTO.EmployeeID, reservation_DTO.StartTime);
                result = Ok(_dbReservation.InsertReservationToDatabase(reservationToAdd));
            }
            catch (SqlException)
            {
                result = Content(HttpStatusCode.InternalServerError, "Could not insert data into database.");
            }
            catch (NullReferenceException)
            {
                result = Content(HttpStatusCode.NotFound, $"The Treatment with the ID ({reservation_DTO.TreatmentID}) was not found.");
            }
            catch (ArgumentException)
            {
                result = Content(HttpStatusCode.Conflict, "There occurred a conflict with the selected time.");
            }

            return(result);
        }
Пример #3
0
        private void btn_Click(object sender, EventArgs e)
        {
            int id_room = (int)((sender as Button).Tag as Room_DTO).Id_room;

            this.room = id_room;

            Room_DTO room = Room_BUS.Instance.Get_Info_Room(this.room);

            if (room.Locked == true)
            {
                Reservation_room_DTO reservation_room = Reservation_room_BUS.Instance.GetInfoReservationRoom(this.room);
                Calendar_DTO         calendar         = Calendar_BUS.Instance.GetInfoCalendarLaster(reservation_room.Reservation.Id_reservation);
                Reservation_DTO      reservation      = Reservation_BUS.Instance.GetInfoReservation(reservation_room.Reservation.Id_reservation);
                lb_name.Text        = reservation.Customer.Name.ToString();
                lb_reservation.Text = reservation_room.Reservation.Id_reservation.ToString();
                lb_startdate.Text   = calendar.Start_date.ToString();
                lb_end_date.Text    = calendar.End_date.ToString();
                lb_type_room.Text   = room.Kind_of_room.Name.ToString();
                lb_people.Text      = room.Kind_of_room.People.ToString();
            }
            else
            {
                lb_name.Text        = "Nope";
                lb_reservation.Text = "Nope";
                lb_startdate.Text   = "Nope";
                lb_end_date.Text    = "Nope";
                lb_type_room.Text   = room.Kind_of_room.Name.ToString();
                lb_people.Text      = room.Kind_of_room.People.ToString();
            }
        }
Пример #4
0
        private void dgv_bill_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int id_bill = (int)dgv_bill.Rows[e.RowIndex].Cells["id"].Value;
                this.id_bill = id_bill;

                Bill_DTO        bill        = Bill_BUS.Instance.GetInfoBill(id_bill);
                Reservation_DTO reservation = Reservation_BUS.Instance.GetInfoReservation(bill.Reservation.Id_reservation);

                lb_reservation.Text = bill.Reservation.Id_reservation.ToString();
                lb_customer.Text    = reservation.Customer.Name.ToString();
                lb_staff.Text       = reservation.Staff.Username.ToString();
                if (bill.Confirm == false)
                {
                    lb_confirm.Text = "Not paid";
                }
                else
                {
                    lb_confirm.Text = "Have Pay";
                }
                lb_created.Text = bill.Created.ToString();
            }
            catch
            {
                MessageBox.Show("Selected Error!");
            }
        }
Пример #5
0
        private void dgv_reservation_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int id_reservation = (int)dgv_reservation.Rows[e.RowIndex].Cells[0].Value;
                this.id_reservation = id_reservation;
                Reservation_DTO reservation = Reservation_BUS.Instance.GetInfoReservation(id_reservation);
                Calendar_DTO    calendar    = Calendar_BUS.Instance.GetCalendarReservationUsing(id_reservation);

                lb_id.Text       = id_reservation.ToString();
                lb_customer.Text = reservation.Customer.Name;
                if (calendar != null)
                {
                    lb_start_date.Text = calendar.Start_date.ToString();
                    lb_end_date.Text   = calendar.End_date.ToString();
                }
                else
                {
                    Calendar_DTO calendar_laster = Calendar_BUS.Instance.GetInfoCalendarLaster(id_reservation);
                    lb_start_date.Text = calendar_laster.Start_date.ToString();
                    lb_end_date.Text   = calendar_laster.End_date.ToString();
                }

                if (reservation.Is_group == true)
                {
                    lb_group.Text = "Yes";
                }
                else
                {
                    lb_group.Text = "No";
                }

                lb_people.Text = reservation.People.ToString();
                if (reservation.Status_reservation == 0)
                {
                    lb_status.Text = "Đã hủy";
                }
                else
                {
                    if (reservation.Status_reservation == 1)
                    {
                        lb_status.Text = "Hoàn tất";
                    }
                    else if (reservation.Status_reservation == 2)
                    {
                        lb_status.Text = "Chưa thanh toán";
                    }
                    else
                    {
                        lb_status.Text = "Chưa Đặt cọc";
                    }
                }
            }
            catch
            {
                MessageBox.Show("Selected Error!");
            }
        }
Пример #6
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            bool flat = true;

            if (int.Parse(lb_number_total_people.Text) < nud_people.Value)
            {
                MessageBox.Show("Error people in room");
                flat = false;
                return;
            }

            if (dtp_endate.Value <= DateTime.Now)
            {
                MessageBox.Show("Error End date");
                flat = false;
                return;
            }

            //if (cb_customer.SelectedIndex == -1)
            //{
            //    MessageBox.Show("You must select customer");
            //    flat = false;
            //    return;
            //}

            //if (cb_group.SelectedIndex == -1)
            //{
            //    MessageBox.Show("You must select Group");
            //    flat = false;
            //    return;
            //}

            if (flat == true)
            {
                Reservation_DTO reservation = new Reservation_DTO();
                ComboboxItem    item        = (ComboboxItem)cb_customer.SelectedItem;
                reservation.Customer.Id_customer = (int)item.Value;
                reservation.Is_group             = false;
                reservation.People         = (int)nud_people.Value;
                reservation.Staff.Username = DTO.Session.username;
                int x = Reservation_BUS.Instance.Insert_Reservation(reservation, dtp_endate.Value, this.list_room);
                if (x != 0)
                {
                    fDeposit frm = new fDeposit();
                    frm.Id_reservation = x;
                    this.Close();
                    frm.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Not insert success!");
                }
            }
            else
            {
                MessageBox.Show("Error!");
            }
        }
Пример #7
0
 public int Insert_Reservation(Reservation_DTO reservation, DateTime end_date, List <Room_DTO> list_room)
 {
     try
     {
         return(Reservation_DAO.Instance.Insert_Reservation(reservation, end_date, list_room));
     }
     catch
     {
         return(0);
     }
 }
Пример #8
0
        public int Insert_Reservation(Reservation_DTO reservation, DateTime end_date, List <Room_DTO> list_room)
        {
            string query = "exec USP_InsertReservation @id_customer , @is_group , @people , @username , @end_date";
            int    x     = (int)Connect.Instance.ExecuteOutPut(query, new object[] { reservation.Customer.Id_customer, reservation.Is_group, reservation.People, reservation.Staff.Username, end_date });

            foreach (Room_DTO room in list_room)
            {
                string query_room = "exec USP_InsertReservationRoom @id_reservation , @id_room";
                Connect.Instance.ExecuteNonQuery(query_room, new object[] { x, room.Id_room });
            }
            return(x);
        }
Пример #9
0
        public List <Reservation_DTO> Search_Reservation(int id_type, string keyword)
        {
            string    query = "exec USP_SearchReservation @id_type , @keyword";
            DataTable table = Connect.Instance.ExecuteQuery(query, new object[] { id_type, keyword });
            List <Reservation_DTO> list_reservation = new List <Reservation_DTO>();

            foreach (DataRow item in table.Rows)
            {
                Reservation_DTO reservation = new Reservation_DTO(item);
                list_reservation.Add(reservation);
            }
            return(list_reservation);
        }
Пример #10
0
        public List <Reservation_DTO> GetListReservation()
        {
            string    query = "exec USP_GetListReservation";
            DataTable table = Connect.Instance.ExecuteQuery(query);
            List <Reservation_DTO> list_reservation = new List <Reservation_DTO>();

            foreach (DataRow item in table.Rows)
            {
                Reservation_DTO reservation = new Reservation_DTO(item);
                list_reservation.Add(reservation);
            }
            return(list_reservation);
        }
Пример #11
0
        public List <Reservation_DTO> GetListReservationByFilter(int type)
        {
            string    query = "exec USP_FilterReservation @type";
            DataTable table = Connect.Instance.ExecuteQuery(query, new object[] { type });
            List <Reservation_DTO> list_reservation = new List <Reservation_DTO>();

            foreach (DataRow item in table.Rows)
            {
                Reservation_DTO reservation = new Reservation_DTO(item);
                list_reservation.Add(reservation);
            }
            return(list_reservation);
        }
        public void TestCreateReservation4_IllegalEmployeeID()
        {
            //Arrange
            Reservation_DTO newReservation = new Reservation_DTO(1, 1, -1, DateTime.Parse("26-11-2025 13:30"));

            //Act
            _watch.Start();
            IHttpActionResult addedReservationResult = _reservationCtrl.Post(newReservation);

            _watch.Stop();

            //Assert
            Assert.IsInstanceOfType(addedReservationResult, typeof(NegotiatedContentResult <string>));
            Assert.IsTrue(((NegotiatedContentResult <string>)addedReservationResult).StatusCode == System.Net.HttpStatusCode.Conflict);
        }
Пример #13
0
        private void LoadData()
        {
            Bill_DTO                    bill                  = Bill_BUS.Instance.GetInfoBill(this.id_bill);
            Reservation_DTO             reservation           = Reservation_BUS.Instance.GetInfoReservation(bill.Reservation.Id_reservation);
            Calendar_DTO                calendar              = Calendar_BUS.Instance.GetCalendarReservationUsing(bill.Reservation.Id_reservation);
            Deposit_DTO                 deposit               = Deposit_BUS.Instance.GetInfoDepositUsing(bill.Reservation.Id_reservation);
            List <Reservation_room_DTO> list_reservation_room = Reservation_room_BUS.Instance.Get_ListReservation_Using(bill.Reservation.Id_reservation);
            List <Service_ticket_DTO>   list_service_ticket   = Service_ticket_BUS.Instance.Get_ListServiceReservation(bill.Reservation.Id_reservation);

            lb_reservation.Text = bill.Reservation.Id_reservation.ToString();
            lb_customer.Text    = reservation.Customer.Name.ToString();
            lb_group.Text       = reservation.Is_group.ToString();
            lb_peopel.Text      = reservation.People.ToString();
            lb_start_date.Text  = calendar.Start_date.ToString();
            lb_end_date.Text    = calendar.End_date.ToString();

            System.Globalization.CultureInfo cul = new System.Globalization.CultureInfo("vi-VN");
            double total_room = Get_Money_Room(list_reservation_room, calendar) + this.Get_Money_Cancel_Room(bill.Reservation.Id_reservation);

            lb_total_room.Text = total_room.ToString("c", cul);

            double total_service = Get_Money_Service(list_service_ticket);

            lb_total_service.Text = total_service.ToString("c", cul);

            this.total_money    = total_room + total_service;
            lb_total_money.Text = this.total_money.ToString("c", cul);


            lb_deposit.Text = deposit.Deposit.ToString("c", cul);
            this.deposit    = deposit.Deposit;

            lb_staff.Text = bill.Staff.Username.ToString();

            lb_rest.Text = (this.total_money - this.deposit).ToString("c", cul);

            Load_Room_Using();
            Load_Service_Using();

            if (Bill_BUS.Instance.CheckConfirmBill(this.id_bill) == true)
            {
                cb_confirm.SelectedIndex = 1;
            }
            else
            {
                cb_confirm.SelectedIndex = 0;
            }
        }
Пример #14
0
        public Reservation_DTO GetInfoReservation(int id_reservation)
        {
            string          query       = "exec USP_GetInfoReservation @id_reservation";
            DataTable       table       = Connect.Instance.ExecuteQuery(query, new object[] { id_reservation });
            Reservation_DTO reservation = new Reservation_DTO();

            foreach (DataRow item in table.Rows)
            {
                reservation.Id_reservation       = (int)item["id_reservation"];
                reservation.Customer.Id_customer = (int)item["id_customer"];
                reservation.Customer.Name        = item["name"].ToString();
                reservation.Is_group             = (bool)item["is_group"];
                reservation.People             = (int)item["people"];
                reservation.Staff.Username     = item["username"].ToString();
                reservation.Status_reservation = (int)item["status_reservation"];
            }
            return(reservation);
        }
        public void TestCreateReservation2_TimeAlreadyBooked()
        {
            //Arrange
            Reservation_DTO newReservation    = new Reservation_DTO(1, 1, 1, DateTime.Parse("26-11-2025 13:30"));
            Reservation_DTO doubleReservation = new Reservation_DTO(1, 1, 1, DateTime.Parse("26-11-2025 13:30"));

            //Act
            _watch.Start();
            IHttpActionResult addedReservation       = _reservationCtrl.Post(newReservation);
            IHttpActionResult addedReservationDouble = _reservationCtrl.Post(doubleReservation);

            _watch.Stop();

            //Assert
            Assert.IsInstanceOfType(addedReservationDouble, typeof(NegotiatedContentResult <string>));
            Assert.IsTrue(((NegotiatedContentResult <string>)addedReservationDouble).StatusCode == System.Net.HttpStatusCode.Conflict);

            Assert.IsTrue(_watch.ElapsedMilliseconds < 2500);
        }
        public void TestCreateReservation1_Valid()
        {
            //Arrange
            Reservation_DTO newReservation = new Reservation_DTO(1, 1, 1, DateTime.Parse("26-11-2025 13:30"));

            //Act
            _watch.Start();
            IHttpActionResult addedReservationResult = _reservationCtrl.Post(newReservation);

            _watch.Stop();

            //Assert
            Assert.IsInstanceOfType(addedReservationResult, typeof(OkNegotiatedContentResult <Reservation>));
            Reservation addedReservationObj = ((OkNegotiatedContentResult <Reservation>)addedReservationResult).Content;

            Assert.AreEqual(newReservation.TreatmentID, addedReservationObj.TreatmentID);
            Assert.AreEqual(newReservation.CustomerID, addedReservationObj.CustomerID);
            Assert.AreEqual(newReservation.EmployeeID, addedReservationObj.EmployeeID);
            Assert.AreEqual(newReservation.StartTime, addedReservationObj.StartTime);
            Assert.IsTrue(_watch.ElapsedMilliseconds < 2500);
        }
        public void TestCreateReservation3_TimeOverlap()
        {
            //Arrange
            Treatment_DTO treatment2 = new Treatment_DTO(1, "Voks af bryst", "Vi benytter enten almindelig varm voks eller sugaring", 60, 399.95m, _categories);

            _treatmentCtrl.Post(treatment2);

            Reservation_DTO newReservation    = new Reservation_DTO(2, 1, 1, DateTime.Parse("26-02-2025 13:30"));
            Reservation_DTO doubleReservation = new Reservation_DTO(1, 1, 1, DateTime.Parse("26-02-2025 14:00"));

            //Act
            _watch.Start();
            IHttpActionResult addedReservationResult       = _reservationCtrl.Post(newReservation);
            IHttpActionResult addedReservationDoubleResult = _reservationCtrl.Post(doubleReservation);

            _watch.Stop();

            //Assert
            Assert.IsInstanceOfType(addedReservationDoubleResult, typeof(NegotiatedContentResult <string>));
            Assert.IsTrue(((NegotiatedContentResult <string>)addedReservationDoubleResult).StatusCode == System.Net.HttpStatusCode.Conflict);
            Assert.IsTrue(_watch.ElapsedMilliseconds < 2500);
        }
        public ActionResult Create(int treatmentID, int customerID, int employeeID, DateTime appointment_date, string appointment_time)
        {
            DateTime appointment_timeObj = DateTime.Parse(appointment_time);

            if (appointment_timeObj.Minute % 30 != 0)
            {
                throw new Exception("Illegal minute... How did You get here?? Begone, hacker! callPoliceOn(this.User);");
            }

            DateTime appointment_dateTime = new DateTime(appointment_date.Year, appointment_date.Month, appointment_date.Day, appointment_timeObj.Hour, appointment_timeObj.Minute, 00);

            RestRequest reservationRequest = new RestRequest("/api/Reservation", Method.POST);

            reservationRequest.AddHeader("Authorization", $"Bearer {Request.Cookies["token"].Value}");
            var reservation_DTO = new Reservation_DTO(
                employeeID: employeeID,
                customerID: customerID,
                treatmentID: treatmentID,
                startTime: appointment_dateTime
                );

            reservationRequest.AddJsonBody(reservation_DTO);
            var response = RestClientManager.Client.Execute(reservationRequest);

            ActionResult viewToReturn;

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                ViewBag.Reservation = JsonConvert.DeserializeObject <Reservation>(response.Content);
                viewToReturn        = View("SuccessView");
            }
            else
            {
                ViewBag.ExceptionAsString = response.Content;
                viewToReturn = View("FailView");
            }

            return(viewToReturn);
        }
        private static void _insertReservation()
        {
            ReservationController reservationCtrl = new ReservationController();
            TreatmentController   treatmentCtrl   = new TreatmentController();

            IHttpActionResult treatmentResult = treatmentCtrl.Get(1);
            Treatment         treatment       = ((OkNegotiatedContentResult <Treatment>)treatmentResult).Content;
            Reservation_DTO   reservation1    = new Reservation_DTO(
                startTime: DateTime.Parse("31-12-2025 23:59"),
                employeeID: 1,
                customerID: 1,
                treatmentID: treatment.ID
                );

            Reservation_DTO reservation2 = new Reservation_DTO(
                startTime: DateTime.Parse("25-10-2026 17:30"),
                employeeID: 1,
                customerID: 1,
                treatmentID: treatment.ID
                );

            reservationCtrl.Post(reservation1);
            reservationCtrl.Post(reservation2);
        }
Пример #20
0
        private void LoadData()
        {
            Room_DTO room = Room_BUS.Instance.Get_Info_Room(this.id_room);

            if (room.Locked == true)
            {
                Reservation_room_DTO reservation_room = Reservation_room_BUS.Instance.GetInfoReservationRoom(this.id_room);
                Calendar_DTO         calendar         = Calendar_BUS.Instance.GetInfoCalendarLaster(reservation_room.Reservation.Id_reservation);
                Reservation_DTO      reservation      = Reservation_BUS.Instance.GetInfoReservation(reservation_room.Reservation.Id_reservation);

                lb_id_reservation.Text     = reservation.Id_reservation.ToString();
                lb_customer.Text           = reservation.Customer.Name.ToString();
                lb_group.Text              = reservation.Is_group.ToString();
                lb_people_reservation.Text = reservation.People.ToString();
                lb_start_date.Text         = calendar.Start_date.ToString();
                lb_end_date.Text           = calendar.End_date.ToString();
                if (reservation.Status_reservation == 0)
                {
                    lb_status_reservation.Text = "Cancel";
                }
                else
                {
                    if (reservation.Status_reservation == 1)
                    {
                        lb_status_reservation.Text = "Success";
                    }
                    else if (reservation.Status_reservation == 2)
                    {
                        lb_status_reservation.Text = "Not paid";
                    }
                    else
                    {
                        lb_status_reservation.Text = "Not deposit";
                    }
                }

                lb_floor.Text     = room.Num_floor.ToString();
                lb_order.Text     = room.Num_order.ToString();
                lb_type_room.Text = room.Kind_of_room.Name.ToString();
                lb_people.Text    = room.Kind_of_room.People.ToString();
                CultureInfo cul = new CultureInfo("vi-VN");
                lb_price.Text = room.Kind_of_room.Price.ToString("c", cul);
                lb_staff.Text = room.Username.ToString();
                if (room.Locked == true)
                {
                    lb_status.Text = "Active";
                }
                else
                {
                    lb_status.Text = "Empty";
                }
            }
            else
            {
                lb_id_reservation.Text     = "Nope";
                lb_customer.Text           = "Nope";
                lb_group.Text              = "Nope";
                lb_people_reservation.Text = "Nope";
                lb_start_date.Text         = "Nope";
                lb_end_date.Text           = "Nope";
                lb_status_reservation.Text = "Nope";

                lb_floor.Text     = room.Num_floor.ToString();
                lb_order.Text     = room.Num_order.ToString();
                lb_type_room.Text = room.Kind_of_room.Name.ToString();
                lb_people.Text    = room.Kind_of_room.People.ToString();
                CultureInfo cul = new CultureInfo("vi-VN");
                lb_price.Text = room.Kind_of_room.Price.ToString("c", cul);
                lb_staff.Text = room.Username.ToString();
                if (room.Locked == true)
                {
                    lb_status.Text = "Active";
                }
                else
                {
                    lb_status.Text = "Empty";
                }
            }

            List <Stuff_detail_DTO> list_stuff = BUS.Stuff_detail_BUS.Instance.Get_List(room.Kind_of_room.Id);

            foreach (Stuff_detail_DTO stuff in list_stuff)
            {
                ListViewItem item = new ListViewItem(stuff.Stuff.Id_stuff.ToString());
                item.SubItems.Add(stuff.Stuff.Name_stuff);
                item.SubItems.Add(stuff.Number.ToString());
                listView1.Items.Add(item);
            }
            lb_used.Text  = BUS.Analytic_BUS.Instance.CountUsingRoom(room.Id_room).ToString();
            lb_stuff.Text = BUS.Analytic_BUS.Instance.CountStuffInRoom(room.Kind_of_room.Id).ToString();
        }
Пример #21
0
        private void Load_Data()
        {
            System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("vi-VN");

            Reservation_DTO reservation = Reservation_BUS.Instance.GetInfoReservation(id_reservation);
            Calendar_DTO    calendar    = Calendar_BUS.Instance.GetCalendarReservationUsing(id_reservation);

            lb_id.Text       = id_reservation.ToString();
            lb_customer.Text = reservation.Customer.Name;
            if (calendar != null)
            {
                lb_start_date.Text = calendar.Start_date.ToString();
                lb_end_date.Text   = calendar.End_date.ToString();
            }
            else
            {
                Calendar_DTO calendar_laster = Calendar_BUS.Instance.GetInfoCalendarLaster(id_reservation);
                lb_start_date.Text = calendar_laster.Start_date.ToString();
                lb_end_date.Text   = calendar_laster.End_date.ToString();
            }

            if (reservation.Is_group == true)
            {
                lb_group.Text = "Yes";
            }
            else
            {
                lb_group.Text = "No";
            }

            lb_people.Text = reservation.People.ToString();
            if (reservation.Status_reservation == 0)
            {
                lb_status.Text = "Đã hủy";
            }
            else
            {
                if (reservation.Status_reservation == 1)
                {
                    lb_status.Text = "Hoàn tất";
                }
                else if (reservation.Status_reservation == 2)
                {
                    lb_status.Text = "Chưa thanh toán";
                }
                else
                {
                    lb_status.Text = "Chưa Đặt cọc";
                }
            }


            List <Calendar_DTO> list_calendar = Calendar_BUS.Instance.GetListCalendarReservation(this.id_reservation);

            foreach (Calendar_DTO calendar1 in list_calendar)
            {
                ListViewItem item = new ListViewItem(calendar1.Id_calendar.ToString());
                item.SubItems.Add(calendar1.Start_date.ToString());
                item.SubItems.Add(calendar1.End_date.ToString());
                item.SubItems.Add(calendar1.Created.ToString());
                if (calendar1.Status == 2)
                {
                    item.SubItems.Add("Change");
                }
                else
                {
                    if (calendar1.Status == 1)
                    {
                        item.SubItems.Add("Active");
                    }
                    else
                    {
                        item.SubItems.Add("Cancel");
                    }
                }

                listView2.Items.Add(item);
            }


            List <Reservation_room_DTO> list_reservation_room = Reservation_room_BUS.Instance.Get_ListReservation_Using(this.id_reservation);

            foreach (Reservation_room_DTO reservation_room in list_reservation_room)
            {
                ListViewItem item = new ListViewItem(reservation_room.Id_reservation_room.ToString());
                item.SubItems.Add(reservation_room.Room.Id_room.ToString());
                item.SubItems.Add(reservation_room.Room.Kind_of_room.Name.ToString());
                item.SubItems.Add(reservation_room.Room.Kind_of_room.People.ToString());
                item.SubItems.Add(((int)reservation_room.Room.Kind_of_room.Price).ToString());
                listView1.Items.Add(item);
            }

            List <Service_ticket_DTO> list_service_reservation = Service_ticket_BUS.Instance.Get_ListServiceReservation(this.id_reservation);

            foreach (Service_ticket_DTO service in list_service_reservation)
            {
                ListViewItem item = new ListViewItem(service.Reservation_room.Room.Id_room.ToString());
                item.SubItems.Add(service.Service.Id_service.ToString());
                item.SubItems.Add(service.Service.Name_service.ToString());
                item.SubItems.Add(((int)service.Service.Price).ToString());
                item.SubItems.Add(service.Number.ToString());
                item.SubItems.Add(service.Date_use.ToString());
                listView4.Items.Add(item);
            }


            List <Deposit_DTO> list_deposit = Deposit_BUS.Instance.GetListDepositReservation(id_reservation);

            foreach (Deposit_DTO deposit in list_deposit)
            {
                ListViewItem item = new ListViewItem(deposit.Id_deposit.ToString());
                item.SubItems.Add(deposit.Deposit.ToString("c", culture));
                item.SubItems.Add(deposit.Confirm.ToString());
                item.SubItems.Add(deposit.Created_confirm.ToString());
                item.SubItems.Add(deposit.Locked.ToString());
                item.SubItems.Add(deposit.Note.ToString());
                listView3.Items.Add(item);
            }

            this.lb_total.Text    = BUS.Bill_BUS.Instance.GetListBillByReservation(id_reservation).Total_money.ToString("c", culture);
            this.lb_checkout.Text = BUS.Bill_BUS.Instance.GetListBillByReservation(id_reservation).Created.ToString();
        }
        private async void CreateBtn_Click(object sender, RoutedEventArgs e)
        {
            if (TreatmentIDBox.Text.Trim().Length == 0 && CustomerIDBox.Text.Trim().Length == 0 && EmployeeIDBox.Text.Trim().Length == 0)
            {
                TreatmentIDBox.Text       = "0";
                CustomerIDBox.Text        = "0";
                EmployeeIDBox.Text        = "0";
                DateSelector.SelectedDate = DateTime.Now;
                TimeCombo.Text            = "19:30";
            }

            string time = TimeCombo.Text;

            FailLbl.Content                = "Der skete en fejl!";
            FailLbl.Opacity                = 0;
            TreatmentIDBox.BorderBrush     = Brushes.Gray;
            TreatmentIDBox.BorderThickness = new Thickness(1, 1, 1, 1);
            CreateButton.BorderBrush       = Brushes.Gray;
            CreateButton.BorderThickness   = new Thickness(1, 1, 1, 1);

            string[] clock     = time.Split(':');
            int      hour      = Int32.Parse(clock[0]);
            int      minutes   = Int32.Parse(clock[1]);
            TimeSpan timeSpan  = new TimeSpan(hour, minutes, 0);
            DateTime startTime = (DateTime)DateSelector.SelectedDate;

            startTime = startTime.Add(timeSpan);

            Reservation_DTO reservationToAdd = new Reservation_DTO(Int32.Parse(TreatmentIDBox.Text),
                                                                   Int32.Parse(CustomerIDBox.Text), Int32.Parse(EmployeeIDBox.Text),
                                                                   startTime);

            RestRequest addRequest = new RestRequest("api/Reservation", Method.POST);

            addRequest.AddJsonBody(reservationToAdd);

            var response = await _client.ExecuteAsync(addRequest);

            if (response.StatusCode == HttpStatusCode.Conflict)
            {
                string message = response.Content;
                FailLbl.Content = FailLbl.Content + "\n" + response.StatusCode + ": " + message;
                FailLbl.Opacity = 100;

                if (message.Contains("TreatmentID"))
                {
                    TreatmentIDBox.BorderBrush     = Brushes.Red;
                    TreatmentIDBox.BorderThickness = new Thickness(1, 1, 1, 1);
                }
                if (message.Contains("CustomerID"))
                {
                    CustomerIDBox.BorderBrush     = Brushes.Red;
                    CustomerIDBox.BorderThickness = new Thickness(1, 1, 1, 1);
                }
                if (message.Contains("EmployeeID"))
                {
                    EmployeeIDBox.BorderBrush     = Brushes.Red;
                    EmployeeIDBox.BorderThickness = new Thickness(1, 1, 1, 1);
                }
                if (message.Contains("occurred a conflict"))
                {
                    TimeCombo.BorderBrush     = Brushes.Red;
                    TimeCombo.BorderThickness = new Thickness(1, 1, 1, 1);
                }
            }
            else if (response.StatusCode == HttpStatusCode.NotFound)
            {
                string message = response.Content;
                FailLbl.Content                = FailLbl.Content + "\n" + response.StatusCode + ": " + message;
                FailLbl.Opacity                = 100;
                TreatmentIDBox.BorderBrush     = Brushes.Red;
                TreatmentIDBox.BorderThickness = new Thickness(1, 1, 1, 1);
            }
            else if (response.StatusCode == HttpStatusCode.InternalServerError)
            {
                string message = response.Content;
                FailLbl.Content              = FailLbl.Content + "\n" + response.StatusCode + ": " + message;
                FailLbl.Opacity              = 100;
                CreateButton.BorderBrush     = Brushes.Red;
                CreateButton.BorderThickness = new Thickness(1, 1, 1, 1);
            }
            else
            {
                string      theJson     = response.Content;
                Reservation reservation = JsonConvert.DeserializeObject <Reservation>(theJson);
                reservation.StartTime = reservation.StartTime.ToLocalTime();
                reservation.EndTime   = reservation.EndTime.ToLocalTime();

                main.ShowCreatedReservation(reservation);

                this.Close();
            }
        }