示例#1
0
        //  Create a report of all the appointment types listed by month,
        //  return a timestamp.
        public static string AppointmentTypeByMonth()
        {
            string report = "";
            string timestamp;

            foreach (DateTime month in Appointments.GetUniqueMonths())
            {
                int appointments = 0;
                int meetings     = 0;
                int kickoffs     = 0;
                int checkins     = 0;
                int reviews      = 0;
                report += month.ToString("MMMM, yyyy") + Environment.NewLine;
                //  Here I used a lambda insead of calling the GetByUniqueMonth Method
                //  in the Appointments class.
                //  I did this because this is more understandable than having a method
                //  call and the mess that is the GetByUniqueMonth method here.
                foreach (Appointment appointment in Appointments.GetBy(a => new DateTime(a.StartDate.Year, a.StartDate.Month, 1) == month))
                {
                    switch (Array.IndexOf(Appointments.TypeArray, appointment.Type))
                    {
                    case 0:
                        appointments++;
                        break;

                    case 1:
                        meetings++;
                        break;

                    case 2:
                        kickoffs++;
                        break;

                    case 3:
                        checkins++;
                        break;

                    case 4:
                        reviews++;
                        break;

                    default:
                        break;
                    }
                }
                report += "Appointments:".PadRight(20) + appointments + Environment.NewLine;
                report += "Meetings:".PadRight(20) + meetings + Environment.NewLine;
                report += "Kick Offs:".PadRight(20) + kickoffs + Environment.NewLine;
                report += "Check Ins:".PadRight(20) + checkins + Environment.NewLine;
                report += "Reviews:".PadRight(20) + reviews + Environment.NewLine;
                report += Environment.NewLine;
            }
            timestamp = DateTime.Now.ToString("yyyyMMddHHmmssffff") + "_APPOINTMENT_TYPE_BY_MONTH_REPORT";
            Log(timestamp + "_APPOINTMENT_TYPE_BY_MONTH_REPORT", report);
            return(timestamp);
        }
示例#2
0
 //  Check for Appointments that are within 15 minutes of log in.
 private void CheckForImmediateAppointments()
 {
     Appointments.GetBy(a => a.User.ID == Users.CurrentUser.ID).ForEach(a =>
     {
         if (a.StartDate.Date == DateTime.Now.Date && a.StartDate <= DateTime.Now.AddMinutes(15))
         {
             AlertUserToNextAppointment(a);
         }
     });
 }
示例#3
0
        //  Create a report of all the appointments listed by user,
        //  return a timestamp.
        public static string AppointmentsByUser()
        {
            string report = "";
            string timestamp;

            foreach (User user in Users.AllUserLists)
            {
                int count = 0;
                report += "User " + Convert.ToString(user.ID).PadRight(5) + user.Name.PadRight(20) + " has a total of ";
                foreach (Appointment appointment in Appointments.GetBy(a => a.User.ID == user.ID))
                {
                    count++;
                }
                report += Convert.ToString(count) + " appointments." + Environment.NewLine;
            }
            timestamp = DateTime.Now.ToString("yyyyMMddHHmmssffff");
            Log(timestamp + "_APPOINTMENTS_BY_CONSULTANT", report);
            return(timestamp);
        }
示例#4
0
        //  Remove a customer from the database.
        public static void Remove(Customer customer)
        {
            if (Appointments.SearchBy(a => a.Customer.ID == customer.ID))
            {
                string message = "Customer " + customer.ID + " has the following appointments:" + Environment.NewLine;
                Appointments.GetBy(a => a.Customer.ID == customer.ID).ForEach(p =>
                {
                    message += "Appointment " + Convert.ToString(p.ID) + Environment.NewLine;
                });
                message += Environment.NewLine + Environment.NewLine;
                message += "Do you want to delete these appointments?";
                throw new UnableToDeleteCustomerException(message);
            }
            else
            {
                Report.UserActivity(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff").PadRight(30) + "USR".PadRight(5) + Convert.ToString(Users.CurrentUser.ID).PadRight(5) + "DEL".PadRight(5) + "CUS".PadRight(5) + Convert.ToString(customer.ID).PadRight(5));

                AllCustomersList.Remove(customer);
                Database.ExecuteQuery(new MySqlCommand("DELETE FROM customer WHERE customerId = " + customer.ID + ";"));
            }
        }
示例#5
0
 private void DeleteCustomer(int id)
 {
     string[] message =
     {
         "Are you sure want to delete customer " + id + " from the database?",
         "¿Estás seguro que quieres borrar el cliente " + id + " del database?"
     };
     string[] title =
     {
         "Warning",
         "Aviso"
     };
     if (MessageBox.Show(message[Global.Language], title[Global.Language], MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
     {
         try
         {
             Customers.Remove(Customers.GetCustomerBy(c => c.ID == id));
         }
         catch (UnableToDeleteCustomerException e)
         {
             if (MessageBox.Show(e.Message, title[Global.Language], MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
             {
                 Appointments.GetBy(a => a.Customer.ID == id).ForEach(a =>
                 {
                     Appointments.Remove(Appointments.GetAppointmentBy(p => p.ID == a.ID));
                 });
                 Customers.Remove(Customers.GetCustomerBy(c => c.ID == id));
                 ResponseLabel.Text = _responsesArray[Convert.ToInt32(Responses.DELETE_CUSTOMER), Global.Language] + Convert.ToString(id);
             }
         }
         finally
         {
             ToggleDashboard();
         }
     }
     else
     {
         ToggleDashboard();
     }
 }
示例#6
0
        private void App15Reminder_Tick(object sender, EventArgs e)
        {
            //  I'm using a double lambda function here! To replace the code below. vvv
            //  Look how hard that is to under stand what's going on!
            Appointments.GetBy(a => a.User.ID == Users.CurrentUser.ID).ForEach(a =>
            {
                if (a.StartDate.Date == DateTime.Now.Date && a.StartDate.Truncate(TimeSpan.TicksPerSecond) == DateTime.Now.Truncate(TimeSpan.TicksPerSecond))
                {
                    AlertUserToNextAppointment(a);
                }
            });

            /*
             * foreach (Appointment appointment in Appointments.GetBy())
             * {
             *  DateTime now = DateTime.Now;
             *  if (new DateTime(appointment.StartDate.Year, appointment.StartDate.Month, appointment.StartDate.Day, appointment.StartDate.Hour, appointment.StartDate.Minute, 0) == new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0).AddMinutes(15))
             *  {
             *      NextAppointmentWarningMessage(appointment);
             *  }
             * }
             */
        }