Exemple #1
0
        public JsonResult createReservationSet(ReservationSet reservationSet)
        {
            if (reservationSet != null)
            {
                using (CasierContents dataContext = new CasierContents())
                {
                    var findItem = dataContext.ItemSet.Where(x => x.Name.Equals(reservationSet.Phone)).FirstOrDefault();
                    if (findItem == null)
                    {
                        dataContext.ReservationSet.Add(reservationSet);
                        dataContext.SaveChanges();
                        var results = new { Success = "True", Message = "Succesfull" };
                        return(Json(results, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        var results = new { Success = "False", Message = "Error" };
                        return(Json(results, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            var result = new { Success = "False", Message = "Error" };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        /// =====================================================================================
        /// Modification : Initial : 26/10/2018 |N.Wilcké (SESA474351)
        ///                          XX/XX/XXXX | X.XXX (SESAXXXXX)
        /// =====================================================================================
        private void updateButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ReservationSet hereReservation = new ReservationSet();
                hereReservation = this.reservation;

                //int idChambre = Util.GetComboId(comboChambre.Text);
                //int idClient = Util.GetComboId(comboClient.Text);

                using (var db = new Model.Booking())
                {
                    ReservationSet reservation = new ReservationSet()
                    {
                        Id = hereReservation.Id
                    };
                    db.ReservationSet.Attach(reservation);

                    //reservation.keyChambre = idChambre;
                    //reservation.keyClient = idClient;
                    reservation.dateDebut = dateDebutDatePicker.DisplayDate.Date;
                    reservation.dateFin   = dateFinDatePicker.DisplayDate.Date;

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemple #3
0
        /// <summary>
        /// add new record
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        /// =====================================================================================
        /// Modification : Initial : 25/10/2018 |N.Wilcké (SESA474351)
        ///                          XX/XX/XXXX | X.XXX (SESAXXXXX)
        /// =====================================================================================
        private void validateReservation_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int idChambre = Util.GetComboId(comboChambre.Text);
                int idClient  = Util.GetComboId(comboClient.Text);

                using (var db = new Model.Booking())
                {
                    ReservationSet reserv = new ReservationSet();
                    reserv.keyChambre = idChambre;
                    reserv.keyClient  = idClient;
                    reserv.dateDebut  = dateDebutDatePicker.DisplayDate.Date;
                    reserv.dateFin    = dateFinDatePicker.DisplayDate.Date;

                    db.ReservationSet.Add(reserv);
                    db.SaveChanges();
                }

                DisplayReservations();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemple #4
0
 /// <summary>
 /// Update
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
 /// =====================================================================================
 /// Modification : Initial : 26/10/2018 |N.Wilcké (SESA474351)
 ///                          XX/XX/XXXX | X.XXX (SESAXXXXX)
 /// =====================================================================================
 private void MenuItem_Click_1(object sender, RoutedEventArgs e)
 {
     try
     {
         ReservationSet row = (ReservationSet)reservationSetDataGrid.SelectedItems[0];
         ((MainWindow)Window.GetWindow(this))._mainFrame.Navigate(new ReservationUpdate(row));
     }
     catch (Exception ex)
     {
         MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK,
                         MessageBoxImage.Information);
     }
 }
Exemple #5
0
 public ReservationUpdate(ReservationSet row)
 {
     InitializeComponent();
     try
     {
         reservation = row;
         dateDebutDatePicker.Text = row.dateDebut.ToString();
         dateFinDatePicker.Text   = row.dateFin.ToString();
         keyChambreTextBox.Text   = row.keyChambre.ToString();
         keyClientTextBox.Text    = row.keyClient.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
Exemple #6
0
        /// <summary>
        /// Delete
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        /// =====================================================================================
        /// Modification : Initial : 25/10/2018 |N.Wilcké (SESA474351)
        ///                          XX/XX/XXXX | X.XXX (SESAXXXXX)
        /// =====================================================================================
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ReservationSet row = (ReservationSet)reservationSetDataGrid.SelectedItems[0];

                using (var db = new Model.Booking())
                {
                    var reservation = new ReservationSet()
                    {
                        Id = row.Id
                    };
                    db.ReservationSet.Attach(reservation);
                    db.ReservationSet.Remove(reservation);
                    db.SaveChanges();
                }

                DisplayReservations();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Internal error :" + Environment.NewLine + ex, "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private void button_rent_Click(object sender, EventArgs e)
        {
            try
            {
                int row = dataGridView_veh_DB.CurrentCell.RowIndex;
                car_id = (int)dataGridView_veh_DB.Rows[row].Cells[0].Value;


                if (comboBox_purpose_of_rent.Text == "Służbowy" || comboBox_purpose_of_rent.Text == "Prywatny" || comboBox_purpose_of_rent.Text == "Delegacja")
                {
                    var counter_modulo = db.RentSets
                                         .Where(x => x.Worker_worker_id == user_id &&
                                                ((x.date_from <= time_from &&
                                                  x.date_to >= time_from) ||
                                                 (x.date_from <= time_to &&
                                                  x.date_to >= time_to)) && x.mileage_end == 0)
                                         .Select(x => x.rent_id)
                                         .Count();


                    if (counter_modulo == 0)
                    {
                        try
                        {
                            ReservationSet newReserv = new ReservationSet()
                            {
                                purpose            = comboBox_purpose_of_rent.Text,
                                date_from          = time_from,
                                date_to            = time_to,
                                Worker_worker_id   = user_id,
                                Vehicle_vehicle_id = car_id
                            };
                            db.ReservationSets.InsertOnSubmit(newReserv);
                            db.SubmitChanges();
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Nie udało się dokonać wypożyczenia pojazdu", "Error Rent", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        try
                        {
                            var mileage_st = (from x in db.VehicleSets
                                              where x.vehicle_id == car_id
                                              select x.mileage)
                                             .Single();

                            ReservationSet reserv = db.ReservationSets
                                                    .Where(x => x.date_to == time_to &&
                                                           x.date_from == time_from &&
                                                           x.Vehicle_vehicle_id == car_id)
                                                    .First();
                            RentSet newRent = new RentSet()
                            {
                                purpose                    = comboBox_purpose_of_rent.Text,
                                date_from                  = time_from,
                                date_to                    = time_to,
                                mileage_start              = mileage_st,
                                Worker_worker_id           = user_id,
                                Reservation_reservation_id = reserv.reservation_id,
                                Vehicle_vehicle_id         = car_id
                            };
                            db.RentSets.InsertOnSubmit(newRent);
                            db.SubmitChanges();

                            MessageBox.Show("Wypożyczyłeś pojazd od dzisiaj do " + time_to.Date.ToShortDateString(), "Good Rent", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            fillDataGridView();
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Nie udało się dokonać wypożyczenia pojazdu", "Error Rent", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else

                    {
                        MessageBox.Show("Masz już wypożyczone auto w takim okresie", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Wybierz cel wypożyczenia", "Error Car", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Zaznacz auto które chcesz wypożyczyć", "Error Car", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void button_reserv_Click(object sender, EventArgs e)
        {
            if (comboBox_service.SelectedIndex == -1 || string.IsNullOrEmpty(textBox_description.Text))
            {
                MessageBox.Show("Wybierz przyczynę serwisu i opisz problem", "Error check", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                int row = dataGridView_care_car_DB.CurrentCell.RowIndex;
                car_id = (int)dataGridView_care_car_DB.Rows[row].Cells[0].Value;
                var count_Reservations = db.ReservationSets
                                         .Where(x => x.Vehicle_vehicle_id == car_id && x.Worker_worker_id == user_id &&
                                                ((x.date_from <= dateTimePicker_from_date_reserv.Value &&
                                                  x.date_to >= dateTimePicker_from_date_reserv.Value) ||
                                                 (x.date_from <= dateTimePicker_to_date_reserv.Value &&
                                                  x.date_to >= dateTimePicker_to_date_reserv.Value)))
                                         .Select(x => x.reservation_id)
                                         .Count();

                if (count_Reservations == 0)
                {
                    try
                    {
                        string     company_name;
                        VehicleSet vechicle = db.VehicleSets.Where(x => x.vehicle_id == car_id).First();

                        //vechicle.available = "no";

                        CareSet care_id = db.CareSets
                                          .Where(x => x.Vehicle_vehicle_id == car_id)
                                          .First();

                        company_name = comboBox_Company_name.Text;

                        CompanySet company_id = db.CompanySets
                                                .Where(x => x.name == company_name)
                                                .First();
                        try
                        {
                            ServiceSet service = new ServiceSet()
                            {
                                is_repair   = false,
                                name        = comboBox_service.Text,
                                description = textBox_description.Text
                            };
                            db.ServiceSets.InsertOnSubmit(service);
                            db.SubmitChanges();
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Nie udało się oddać auta do serwisu", "Error check", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        try
                        {
                            ServiceSet service = db.ServiceSets.OrderByDescending(p => p.service_id).First();

                            Care_serviceSet newservice = new Care_serviceSet()
                            {
                                date_from          = dateTimePicker_from_date_reserv.Value,
                                data_to            = Convert.ToDateTime("1999-01-01 00:00:00.000"),
                                Care_care_id       = care_id.care_id,
                                Service_service_id = service.service_id,
                                price = -10,
                                Company_company_id = company_id.company_id
                            };
                            db.Care_serviceSets.InsertOnSubmit(newservice);
                            db.SubmitChanges();
                            MessageBox.Show("Zarezerwowałeś pojazd od " + dateTimePicker_from_date_reserv.Value.ToShortDateString(), "Good Reservation", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            fillDataGridView();
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Nie dodało się do bazy care_service", "Error check", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        try
                        {
                            WorkerSet worker;

                            try
                            {
                                var people = (from x in db.ReservationSets
                                              where ((x.date_from >= dateTimePicker_from_date_reserv.Value && x.date_from <= dateTimePicker_to_date_reserv.Value) ||
                                                     (x.date_to >= dateTimePicker_from_date_reserv.Value && x.date_to <= dateTimePicker_to_date_reserv.Value) ||
                                                     (x.date_from >= dateTimePicker_from_date_reserv.Value && x.date_to <= dateTimePicker_to_date_reserv.Value)) &&
                                              x.Vehicle_vehicle_id == vechicle.vehicle_id &&
                                              x.Worker_worker_id != user_id
                                              select x.Worker_worker_id).Distinct();

                                string peoples = "Powiadom następujące osoby o wysyłaniu pojazdu na serwis w terminie ich rezerwacji, oraz poproś o usunięcie owej rezerwacji: \n ";
                                foreach (int id in people)
                                {
                                    worker = db.WorkerSets.Where(x => x.worker_id == id).SingleOrDefault();

                                    peoples += worker.name + " " + worker.surname + " nr telefonu do pracownika: " + worker.phone_nr.ToString() + "\n";
                                }

                                if (peoples == "Powiadom następujące osoby o wysyłaniu pojazdu na serwis w terminie ich rezerwacji, oraz poproś o usunięcie owej rezerwacji: \n ")
                                {
                                }
                                else
                                {
                                    MessageBox.Show(peoples, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                            catch (Exception)
                            {
                            }
                            ReservationSet newreserv = new ReservationSet()
                            {
                                date_from          = dateTimePicker_from_date_reserv.Value,
                                date_to            = dateTimePicker_to_date_reserv.Value,
                                purpose            = "Serwis",
                                Worker_worker_id   = user_id,
                                Vehicle_vehicle_id = vechicle.vehicle_id
                            };

                            db.ReservationSets.InsertOnSubmit(newreserv);
                            db.SubmitChanges();
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Nie udało się stworzyć rezerwacji", "Error check", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Zaznacz samochód", "Error check", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Masz już zarezerwowane auto w takim okresie", "Error Reservation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void button_reserv_Click(object sender, EventArgs e)
        {
            if (confirm)
            {
                try
                {
                    int row = dataGridView_veh_DB.CurrentCell.RowIndex;
                    car_id = (int)dataGridView_veh_DB.Rows[row].Cells[0].Value;

                    if (comboBox_purpose_of_reservation.Text == "Służbowy" || comboBox_purpose_of_reservation.Text == "Prywatny" || comboBox_purpose_of_reservation.Text == "Delegacja")
                    {
                        var count_Reservations = db.ReservationSets
                                                 .Where(x => x.Worker_worker_id == id_user &&
                                                        ((x.date_from <= time_from &&
                                                          x.date_to >= time_from) ||
                                                         (x.date_from <= time_to &&
                                                          x.date_to >= time_to)))
                                                 .Select(x => x.reservation_id)
                                                 .Count();
                        if (count_Reservations == 0)
                        {
                            try
                            {
                                ReservationSet newReservation = new ReservationSet()
                                {
                                    purpose            = comboBox_purpose_of_reservation.Text,
                                    date_from          = time_from.Date,
                                    date_to            = time_to.Date,
                                    Worker_worker_id   = id_user,
                                    Vehicle_vehicle_id = car_id
                                };

                                db.ReservationSets.InsertOnSubmit(newReservation);
                                db.SubmitChanges();



                                MessageBox.Show("Zarezerwowałeś pojazd od " + time_from.Date.ToShortDateString() + " do " + time_to.Date.ToShortDateString(), "Good Reservation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Nie udało się dokonać rezerwacji pojazdu", "Error Reservation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Masz już zarezerwowane auto w takim okresie", "Error Reservation", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Wybierz cel rezerwacji", "Error Car", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Zaznacz auto które chcesz zarezerwować", "Error Car", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Wybierz datę", "Error Car", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }