示例#1
0
        //private void CheckTimeOverLap(AppointmentCollection collection, Appointment appointment)
        //{
        //    try
        //    {
        //        collection.ObservableList.ForEach(x => x.IsAppointmentOverlapped = false);
        //        appointment.IsAppointmentOverlapped = false;
        //        var query =
        //            collection.ObservableList.Where(
        //                x =>
        //                x.EndTime > appointment.BeginTime &&
        //                x.BeginTime < appointment.EndTime);
        //        var appointments = query as IList<Appointment> ?? query.ToList();
        //        if (appointments.Any(x =>
        //            {
        //                if (!appointment.ID.HasValue)
        //                    return true;
        //                return appointment.ID != x.ID;
        //            }))
        //        {
        //            appointments.ForEach(x => x.IsAppointmentOverlapped = true);
        //            appointment.IsAppointmentOverlapped = true;
        //        }

        //    }
        //    catch (Exception exception)
        //    {
        //        NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured,
        //                            ExceptionResources.ExceptionOccuredLogDetail);
        //    }
        //}

        private void GetAppointmentsByDate(Appointment appointment, bool doAsync = false, bool findNextAppointment = false)
        {
            try
            {
                if (doAsync)
                {
                    Task.Factory.StartNew(() =>
                    {
                        this.AppointmentCollection = AppointmentAction.GetAppointments(this.DBConnectionString,
                                                                                       appointment.AppointmentDate);

                        this.ShowProgressBar = false;
                    });
                }
                else
                {
                    this.AppointmentCollection = AppointmentAction.GetAppointments(this.DBConnectionString,
                                                                                   appointment.AppointmentDate);
                    this.ShowProgressBar = false;
                }
            }
            catch (Exception exception)
            {
                NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured,
                                    ExceptionResources.ExceptionOccuredLogDetail);
            }
        }
        private void DeleteCustomerAppointment(DialogResult dialogResult)
        {
            if (dialogResult == DialogResult.Ok)
            {
                Task.Factory.StartNew(() =>
                {
                    var result = AppointmentAction.DeleteAppointments(this.DBConnectionString,
                                                                      this.Entity.InternalList.Where(x => x.IsSelected));

                    if (result)
                    {
                        this.GetCustomerAppointments();
                        var messageDailog = new MessageDailog()
                        {
                            Caption = MessageResources.DeletedSuccessfully, DialogButton = DialogButton.Ok, Title = TitleResources.Information
                        };
                        MessengerInstance.Send(messageDailog);
                    }
                    else
                    {
                        var messageDailog = new MessageDailog()
                        {
                            Caption = MessageResources.DeletionFailed, DialogButton = DialogButton.Ok, Title = TitleResources.Error
                        };
                        MessengerInstance.Send(messageDailog);
                    }
                    ShowProgressBar = false;
                });
            }
            else
            {
                ShowProgressBar = false;
            }
        }
        public AppointmentOperation(AppointmentAction action, Type view)
        {
            if (action == AppointmentAction.Unknown)
            {
                throw new ArgumentException("Action cannot be unknown");
            }

            Action = action;
            View   = view ?? throw new ArgumentNullException(nameof(view));
        }
示例#4
0
        /// <summary>
        /// This function handles what to do when appointments in upcoming and pending are clicked.
        /// </summary>
        /// <param name="a_sender">It holds the sender.</param>
        /// <param name="a_event">It holds the event.</param>
        private void HandleAppointmentClick(object a_sender, EventArgs a_event)
        {
            MetroTile   tile = (MetroTile)a_sender;
            Appointment app  = (Appointment)tile.Tag;

            /// Opens the appointment action form that takes in the appointment object and
            /// if it is student or not for appropriate actions.
            AppointmentAction actionForm = new AppointmentAction(app, m_isStudent);

            actionForm.ShowDialog();

            /// Refreshes the UI of the controller.
            RefreshController();
        }
 private void GetCustomerAppointments()
 {
     Task.Factory.StartNew(() =>
     {
         try
         {
             this.Entity = AppointmentAction.GetAppointments(this.DBConnectionString, this.SelectedCustomer);
         }
         catch (Exception exception)
         {
             NLogLogger.LogError(exception, TitleResources.Error, ExceptionResources.ExceptionOccured,
                                 ExceptionResources.ExceptionOccuredLogDetail);
         }
     });
 }
示例#6
0
        private void OnSaveAppointment()
        {
            this.ShowProgressBar = true;
            //if (!this.Entity.IsValidAppiontSechduleDateRange)
            //{
            //    var msg = new MessageDailog() { Caption = Resources.MessageResources.InvalidAppointmentDate, DialogButton = DialogButton.Ok, Title = Resources.TitleResources.Warning };
            //    MessengerInstance.Send(msg);
            //    return;
            //}
            bool returnStatus = false;

            if (!this.Entity.ID.HasValue)
            {
                returnStatus = AppointmentAction.AddAppointment(this.DBConnectionString, this.Entity);
            }
            if (this.Entity.ID.HasValue)
            {
                returnStatus = AppointmentAction.UpdateAppointment(this.DBConnectionString, this.Entity);
            }

            if (returnStatus)
            {
                this.Entity = new Appointment();
                this.PropertyChangedCapture();
                this.GetAppointmentsByDate(this.Entity, true, true);

                if (RefreshCustomerAppointment != null)
                {
                    RefreshCustomerAppointment();
                }
                this.CheckItemCollection.ForEach(x => x.IsChecked = false);
            }

            var messageDailog = returnStatus ? new MessageDailog()
            {
                Caption = Resources.MessageResources.DataSavedSuccessfully, DialogButton = DialogButton.Ok, Title = Resources.TitleResources.Information
            } :
            new MessageDailog()
            {
                Caption = Resources.MessageResources.DataSavedFailed, DialogButton = DialogButton.Ok, Title = Resources.TitleResources.Error
            };

            MessengerInstance.Send(messageDailog);

            this.ShowProgressBar = false;
        }