private void btnUpdateAppointment_Click(object sender, EventArgs e)
        {
            if (!Controller.ValidateTextBoxes(this))
            {
                return;
            }
            if (!Controller.ValidateDateTime(dtStart, dtEnd))
            {
                return;
            }
            main1.updateCalled    = false;
            _singleAppointment[2] = txtAppointmentTitle.Text;

            _singleAppointment[6] = txtAppointmentType.Text;
            _singleAppointment[3] = txtAppointmentDescription.Text;
            _singleAppointment[4] = txtAppointmentLocation.Text;
            _singleAppointment[7] = txtAppointmentURL.Text;
            _singleAppointment[5] = txtAppointmentContact.Text;
            _singleAppointment[8] = dtStart.Value.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss");
            _singleAppointment[9] = dtEnd.Value.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss");

            bool result = Controller.updateAppointment(_singleAppointment);

            if (result)
            {
                main1.RefreshGrid();
                MessageBox.Show("This appointment has been successfully updated.");
            }
            else
            {
                MessageBox.Show("This appointment has NOT been updated.");
            }

            this.Dispose(false);
            this.Close();
        }
Пример #2
0
        private void btnInsertAppointment_Click(object sender, EventArgs e)
        {
            if (!Controller.ValidateTextBoxes(this))
            {
                return;
            }
            if (!Controller.ValidateDateTime(dtStart, dtEnd))
            {
                return;
            }
            Appointment appointmentInfo = new Appointment();
            int         customerId;

            int.TryParse(txtCustomerId.Text, out customerId);
            appointmentInfo.customerId  = customerId;
            appointmentInfo.userId      = Controller.retrieveUserId();
            appointmentInfo.title       = txtAppointmentTitle.Text;
            appointmentInfo.description = txtAppointmentDescription.Text;
            appointmentInfo.location    = txtAppointmentLocation.Text;
            appointmentInfo.contact     = txtAppointmentContact.Text;
            appointmentInfo.type        = txtAppointmentType.Text;
            appointmentInfo.url         = txtAppointmentURL.Text;
            appointmentInfo.start       = dtStart.Value;
            appointmentInfo.end         = dtEnd.Value;


            DialogResult confirmInsert = MessageBox.Show("Are you sure that you want to add this appointment?", "Confirm?", MessageBoxButtons.YesNo);

            if (confirmInsert == DialogResult.Yes)
            {
                bool result = Controller.insertAppointment(appointmentInfo);
                if (result)
                {
                    main1.RefreshGrid();
                    MessageBox.Show($"Appointment with: {appointmentInfo.contact} has been successfully added.");
                }
                else
                {
                    MessageBox.Show($"ERROR: Appointment with:: {appointmentInfo.contact} has NOT been added.");
                }

                this.Dispose(false);
                this.Close();
            }
        }