private void showBookingWithType(int bookingId, string bookingType)
        {
            BookingServiceReference.Booking booking = bookingService.GetBooking(bookingId);

            if (bookingType == "ReadyToGo")
            {
                BookingServiceReference.ReadyToGo readyToGo = bookingService.GetReadyToGo(bookingId);

                //Viser formen
                ShowBookingForms.ShowReadyToGoForm showReadyToGoForm = new ShowReadyToGoForm(booking, readyToGo);
                showReadyToGoForm.Show();
            }
            else if (bookingType == "Task")
            {
                BookingServiceReference.SupportTask supportTask = bookingService.GetSupportTask(bookingId);

                //Viser formen
                ShowBookingForms.ShowTaskForm showTaskForm = new ShowTaskForm(booking, supportTask);
                showTaskForm.Show();
            }
            else if (bookingType == "SupportBooking")
            {
                BookingServiceReference.SupportBooking supportBooking = bookingService.GetSupportBooking(bookingId);

                //Viser formen
                ShowBookingForms.ShowSupportBookingForm showSupportBookingForm = new ShowSupportBookingForm(booking, supportBooking);
                showSupportBookingForm.Show();
            }
            else
            {
                MessageBox.Show("Fejl kunne ikke hente booking typen", "Booking type fejl");
            }
        }
예제 #2
0
 public void CreateReadyToGo(BookingServiceReference.ReadyToGo readyToGo)
 {
     bookingService.CreateReadyToGo(readyToGo);
 }
        private void btnCreateRTG_MouseClick(object sender, MouseEventArgs e)
        {
            BookingServiceReference.ReadyToGo readyToGo = new BookingServiceReference.ReadyToGo(); //Opretter en tom RTG
            DateTime date;
            DateTime time;
            DateTime dateTime;

            //Udfylder felter til RTG
            date = dtpDate.Value.Date;

            //Tjekker på hvilken service det er, og sætter tid efter dette
            time     = Convert.ToDateTime(cbEndDate.Text);
            dateTime = date.Date + time.TimeOfDay;
            if (cbService.Text == "Pc")
            {
                if (chbOffice.Checked)
                {
                    readyToGo.EndDate   = Convert.ToDateTime(dateTime).AddHours(-1.5); //Regner s**t tid tilbage
                    readyToGo.StartDate = readyToGo.EndDate.AddHours(-0.5);            //Regner start tid ud fra s**t tid
                }
                else
                {
                    readyToGo.EndDate   = Convert.ToDateTime(dateTime).AddHours(-1.67);
                    readyToGo.StartDate = readyToGo.EndDate.AddHours(-0.33);
                }
            }
            else if (cbService.Text == "Tv")
            {
                readyToGo.EndDate   = Convert.ToDateTime(dateTime);
                readyToGo.StartDate = readyToGo.EndDate.AddHours(-0.42);
            }
            else if (cbService.Text == "Mobil")
            {
                readyToGo.EndDate   = Convert.ToDateTime(dateTime);
                readyToGo.StartDate = readyToGo.EndDate.AddHours(-0.5);
            }
            else if (cbService.Text == "Tablet")
            {
                readyToGo.EndDate   = Convert.ToDateTime(dateTime);
                readyToGo.StartDate = readyToGo.EndDate.AddHours(-0.33);
            }
            else if (cbService.Text == "Gps")
            {
                readyToGo.EndDate   = Convert.ToDateTime(dateTime).AddHours(-4.0);
                readyToGo.StartDate = readyToGo.EndDate.AddMinutes(-3.33);
            }
            else if (cbService.Text == "Ur")
            {
                readyToGo.EndDate   = Convert.ToDateTime(dateTime);
                readyToGo.StartDate = readyToGo.EndDate.AddHours(-0.58);
            }
            else if (cbService.Text == "Spillekonsol")
            {
                readyToGo.EndDate   = Convert.ToDateTime(dateTime);
                readyToGo.StartDate = readyToGo.EndDate.AddHours(-2.0);
            }

            //Tilføjer tillægsydelser til RTG'en
            if (chbOffice.Checked && chbInstallPrinter.Checked)
            {
                readyToGo.AdditionalServices = "Installer offige og printer";
            }
            else if (chbOffice.Checked)
            {
                readyToGo.AdditionalServices = "Installer office";
            }
            else if (chbInstallPrinter.Checked)
            {
                readyToGo.AdditionalServices = "Installer printer";
            }
            else
            {
                readyToGo.AdditionalServices = "";
            }

            readyToGo.AppendixNr = Convert.ToInt32(txtAppendixNr.Text);
            readyToGo.ProductNr  = txtProductNr.Text;

            //Tjekker om RTG her en kontrakt
            if (rbYesContract.Checked)
            {
                readyToGo.Contract = true;
            }
            else
            {
                readyToGo.Contract = false;
            }

            //Tilføjer userid
            readyToGo.User_Id     = user.Id;
            readyToGo.BookingType = "ReadyToGo";

            int calendarId = bookingService.FindAvaibleCalendar(readyToGo.StartDate, readyToGo.EndDate);

            if (calendarId > 0)
            {
                readyToGo.Calendar_Id = calendarId;
                try
                {
                    bookingService.CreateReadyToGo(readyToGo); //Sender RTG'en vidre til service, og bliver senere gemt i db.
                    string s = string.Format("RTG oprettet og kan afhentes kl: {0}", Convert.ToDateTime(dateTime));
                    MessageBox.Show(s, "RTG oprettet");
                }
                catch
                {
                    MessageBox.Show("Kunne ikke oprette booking", "Fejl");
                }
            }
            else
            {
                MessageBox.Show("Der er en tid på dette tidspunkt", "Tid taget");
            }
        }