Exemple #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!Check())
            {
                return;
            }

            Appointment ap = new Appointment();

            ap.ConfirmedBy   = txtConfirmedBy.Text;
            ap.CustomerGroup = cbCustomerGroup.Text;
            ap.Date          = date.Value;


            string startTime = GetTime((int)nudStartHour.Value, (int)nudStartMin.Value,
                                       cbStartTime.SelectedIndex == 0 ? "AM" : "PM");
            string endTime = GetTime((int)nudEndHour.Value, (int)nudEndMin.Value,
                                     cbEndTime.SelectedIndex == 0 ? "AM" : "PM");

            ap.StartTime = startTime;
            ap.EndTime   = endTime;

            ap.Location = txtLocation.Text.Trim();

            ap.Requestor    = txtRequestor.Text.Trim();
            ap.CustomerName = txtTitle.Text.Trim();


            CurrentAppointment = ap;

            if (Update)
            {
                CurrentAppointment.ID = UpdateId;
                this.ap.Update(CurrentAppointment);
                AppointmentUpdated?.Invoke();
            }
            else
            {
                CurrentAppointment.ID = this.ap.AddAppointment(ap, UserData.UserId);
                AppointmentAdded?.Invoke();
            }

            Reset();
            this.Hide();
        }
 /// <summary>
 /// Invoke AppointmentAdded event
 /// </summary>
 /// <param name="appointment">Added appointment</param>
 internal static void Call_AppointmentAdded(Appointment appointment)
 {
     AppointmentAdded?.Invoke(appointment);
 }