Esempio n. 1
0
        private void sbmt_btn_Click(object sender, RoutedEventArgs e)
        {
            int      time_id;
            DateTime dt = calendar.SelectedDate.Value;

            if (sh != null)
            {
                if (yes_lsb.IsSelected == true)
                {
                    db1.shift.Remove(sh);
                    db1.SaveChanges();
                    this.Close();
                }
                if (mornng_rdb.IsChecked == false && evnng_rdb.IsChecked == false)
                {
                    msg_lsb.Items.Add("Failure Enter the time");
                }
                else if (calendar.SelectedDate == null)
                {
                    msg_lsb.Items.Add("Failure! Select the date");
                }
                else if (calendar.SelectedDate.Value.DayOfWeek.ToString() == "Friday" || calendar.SelectedDate.Value.DayOfWeek.ToString() == "Saturday")
                {
                    msg_lsb.Items.Add("Failure! The Pizza doesn't work on this day");
                }
                else
                {
                    if (mornng_rdb.IsChecked == true)
                    {
                        time_id = 1;
                    }
                    else
                    {
                        time_id = 2;
                    }
                    shift_time sht = db1.shift_time.ToArray()[time_id - 1];
                    sh.date          = dt;
                    sh.shift_time    = sht;
                    sh.shift_time_id = time_id;
                    MessageBox.Show("The shift has been changed", "Succes", MessageBoxButton.OK, MessageBoxImage.Information);
                    db1.SaveChanges();
                    this.Close();
                }
            }
            else
            {
                msg_lsb.Items.Add("Failure! Select the shift");
            }
        }
Esempio n. 2
0
        private void sbmt_btn_Click(object sender, RoutedEventArgs e)
        {
            int id_time;

            if (calendar.SelectedDate == null)
            {
                msg_lsb.Items.Add("Failure! Enter the date");
            }
            else if (calendar.SelectedDate.Value.DayOfWeek.ToString() == "Friday" || calendar.SelectedDate.Value.DayOfWeek.ToString() == "Saturday")
            {
                msg_lsb.Items.Add("Failure! The Pizza doesn't work on this day");
            }
            else if (mornng_rdb.IsChecked == false && evnng_rdb.IsChecked == false)
            {
                msg_lsb.Items.Add("Failure Enter the time");
            }
            else if (emp == null)
            {
                msg_lsb.Items.Add("Failure! Select the worker");
            }
            else
            {
                if (mornng_rdb.IsChecked == true)
                {
                    id_time = 1;
                }
                else
                {
                    id_time = 2;
                }
                DateTime   dt        = calendar.SelectedDate.Value;
                shift_time sht       = db1.shift_time.ToArray()[id_time - 1];
                shift      shift_emp = new shift {
                    shift_time = sht, shift_time_id = id_time, employee = emp, date = dt, time_of_working = Convert.ToDecimal(0.00)
                };
                if (!IsAlreadyShift(shift_emp))
                {
                    this.db1.shift.Add(shift_emp);
                    this.db1.SaveChanges();
                    MessageBox.Show("The shift has been added", "Succes", MessageBoxButton.OK, MessageBoxImage.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("The shift you want to add is already exist in the system", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
        }