public ActionResult AddClient(Client client)
 {
     if (!ModelState.IsValid)
     {
         return(AddClient(client));
     }
     else
     {
         int clientID = insertObjectToDB.GetClientIdAndInsertToDB(client.client_name, client.client_sname, client.client_phone, client.client_description);
         if (clientID == -1)
         {
             return(RedirectToAction("info1", new { messageWindow = "Bład przy dodawaniu nowego klienta" }));
         }
         return(RedirectToAction("Index", "Reservation", new { visibleTrue = false }));
     }
 }
Beispiel #2
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);
        }