Beispiel #1
0
        private Appointment BuildAppointment(DateTime timestamp)
        {
            Appointment appointment;

            if (_isUpdate)
            {
                appointment = Appointments.GetAppointmentBy(a => a.ID == Convert.ToInt32(AppointmentIDField.Text));
                //  We do not update the create date or creat by.
                appointment.UpdateTimestamp = timestamp;
                appointment.UpdateBy        = Users.CurrentUser;
            }
            else
            {
                appointment                 = new Appointment(Appointments.GetNextID());
                appointment.CreateDate      = timestamp;
                appointment.CreateBy        = Users.CurrentUser;
                appointment.UpdateTimestamp = timestamp;
                appointment.UpdateBy        = Users.CurrentUser;
            }
            appointment.Customer    = Customers.GetCustomerBy(c => c.ID == Convert.ToInt32(CustomerDropList.SelectedValue));
            appointment.User        = Users.GetUserBy(u => u.ID == Convert.ToInt32(UserDropList.SelectedValue));
            appointment.Title       = TitleField.Text;
            appointment.Description = DescriptionField.Text;
            appointment.Location    = Convert.ToString(LocationDropList.SelectedValue);
            appointment.Contact     = ContactField.Text;
            appointment.Type        = Convert.ToString(TypeDropList.SelectedValue);
            appointment.URL         = URLField.Text;
            appointment.StartDate   = Convert.ToDateTime(StartDatePicker.Value.ToString("yyyy-MM-dd") + " " + StartTimePicker.Value.ToString("HH:mm:ss"));
            appointment.EndDate     = Convert.ToDateTime(EndDatePicker.Value.ToString("yyyy-MM-dd") + " " + EndTimePicker.Value.ToString("HH:mm:ss"));

            return(appointment);
        }
Beispiel #2
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();
     }
 }
Beispiel #3
0
        private void DeleteAppointment(int id)
        {
            string[] message =
            {
                "Are you sure want to delete appointment " + id + " from the database?",
                "¿Estás seguro que quieres borrar la cita " + id + " del database?"
            };
            string[] title =
            {
                "Warning",
                "Aviso"
            };
            if (MessageBox.Show(message[Global.Language], title[Global.Language], MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
            {
                Appointments.Remove(Appointments.GetAppointmentBy(a => a.ID == id));
                ResponseLabel.Text = _responsesArray[Convert.ToInt32(Responses.DELETE_APPOINTMENT), Global.Language] + Convert.ToString(id);

                ToggleDashboard();
            }
            else
            {
                ToggleDashboard();
            }
        }
Beispiel #4
0
        private void AppointmentInspector_Load(object sender, EventArgs e)
        {
            if (_isUpdate)
            {
                Appointment appointment = Appointments.GetAppointmentBy(a => a.ID == _appointmentID);
                AppointmentIDField.Text        = Convert.ToString(appointment.ID);
                CustomerDropList.DataSource    = Customers.AllCustomersList;
                CustomerDropList.ValueMember   = "ID";
                CustomerDropList.DisplayMember = "Name";
                CustomerDropList.SelectedItem  = appointment.Customer;
                UserDropList.DataSource        = Users.AllUserLists;
                UserDropList.ValueMember       = "ID";
                UserDropList.DisplayMember     = "Name";
                UserDropList.SelectedItem      = appointment.User;
                TitleField.Text                = appointment.Title;
                DescriptionField.Text          = appointment.Description;
                URLField.Text                  = appointment.URL;
                ContactField.Text              = appointment.Contact;
                TypeDropList.DataSource        = Appointments.TypeArray;
                TypeDropList.SelectedIndex     = Array.IndexOf(Appointments.TypeArray, appointment.Type);
                LocationDropList.DataSource    = Appointments.LocationArray;
                LocationDropList.SelectedIndex = Array.IndexOf(Appointments.LocationArray, appointment.Location);
                StartDatePicker.Value          = appointment.StartDate;
                StartTimePicker.Value          = appointment.StartDate;
                EndDatePicker.Value            = appointment.EndDate;
                EndTimePicker.Value            = appointment.EndDate;
                DateCreatedField.Text          = appointment.CreateDate.Date.ToString("MM/dd/yyyy");;
                CreatedByField.Text            = appointment.CreateBy.Name;
                DateUpdatedField.Text          = appointment.UpdateTimestamp.ToString("MM/dd/yyyy HH:mm:ss");
                UpdatedByField.Text            = appointment.UpdateBy.Name;
            }
            else
            {
                CustomerDropList.DataSource    = Customers.AllCustomersList;
                CustomerDropList.ValueMember   = "ID";
                CustomerDropList.DisplayMember = "Name";
                CustomerDropList.SelectedIndex = 0;
                UserDropList.DataSource        = Users.AllUserLists;
                UserDropList.ValueMember       = "ID";
                UserDropList.DisplayMember     = "Name";
                UserDropList.SelectedItem      = Users.CurrentUser;
                ContactField.Text              = Customers.GetCustomerBy(c => c.ID == Convert.ToInt32(CustomerDropList.SelectedValue)).Address.Phone;
                TypeDropList.DataSource        = Appointments.TypeArray;
                TypeDropList.SelectedIndex     = 0;
                LocationDropList.DataSource    = Appointments.LocationArray;
                LocationDropList.SelectedIndex = 0;
                StartDatePicker.Value          = ToNext30(DateTime.Now);
                StartTimePicker.Value          = ToNext30(DateTime.Now);
                DateCreatedField.Visible       = false;
                DateCreatedLabel.Visible       = false;
                CreatedByField.Visible         = false;
                CreatedByLabel.Visible         = false;
                DateUpdatedField.Visible       = false;
                DateUpdatedLabel.Visible       = false;
                UpdatedByField.Visible         = false;
                UpdatedByLabel.Visible         = false;
            }

            CustomerDropList.SelectedIndexChanged += CustomerDropList_SelectedIndexChanged;
            ToggleOkButton();
        }