Ejemplo n.º 1
0
        public void insertNewReservation()
        {
            int servicesID = -1;
            int clientID   = -1;

            if (ckbNewClient.Checked)
            {
                clientID = insertObjectToDB.GetClientIdAndInsertToDB(txbClientName.Text, txbClientSName.Text, txbClientPhone.Text, txbClientDescription.Text);
            }
            else
            {
                if (cmbClientList.SelectedIndex == 0)
                {
                    MessageBox.Show("Wybierz klienta");
                    return;
                }
                clientID = cmbClientList.SelectedIndex;
            }
            if (ckbNewServices.Checked)
            {
                servicesID = insertObjectToDB.GetServicesIdAndInsertDB(txbNewServices.Text);
            }
            else
            {
                if (cmbListServices.SelectedIndex == 0)
                {
                    MessageBox.Show("Wybierz usługę");
                    return;
                }
                servicesID = cmbListServices.SelectedIndex;
            }
            if (tscmbEmployee.ComboBox.SelectedIndex == 0)
            {
                MessageBox.Show("Wybierz pracownika");
                return;
            }
            if (!insertObjectToDB.GetReservationIdAndInsertToDB(dtpReservationDate.Value, Convert.ToInt32(nudHour.Value), Convert.ToInt32(nudMinute.Value),
                                                                clientID, servicesID, tscmbEmployee.SelectedIndex))
            {
                MessageBox.Show("Nie można dodać reserwacji w tym terminie. Jest on zajęty");
                return;
            }
            GridBuilder.FillTheGrid(getVReservation.GetVReservations(), dgvVReservation);
            ComboBoxSetData.SetDataToCmbClient(cmbClientList);
            ComboBoxSetData.SetDataToCmbServices(cmbListServices);
            FillClientControls(null, true);
        }
Ejemplo n.º 2
0
        public ActionResult AddReservation(Reservation reservation, string findClient)
        {
            int clientId = reservation.client_id;

            if (!String.IsNullOrEmpty(findClient))
            {
                var clientList = selectClient.GetRowsForTable(SGetAllRowsFromSpecificTable.ClientSelectAllRowsQuery())
                                 .Select(x => new
                {
                    desccription = x.client_name + " " + x.client_sname + " " + x.client_phone + " " + x.client_description,
                    clientId     = x.client_id
                }).ToList();

                clientId = clientList.Where(x => x.desccription.Contains(findClient)).First().clientId;
            }
            insertObjectToDB.GetReservationIdAndInsertToDB(reservation.reservation_date, reservation.reservation_time.Hours, reservation.reservation_time.Minutes,
                                                           clientId, reservation.services_id, reservation.employee_id);

            return(RedirectToAction("Index", "Reservation", new { visibleTrue = false }));
        }