Example #1
0
 /// <summary>
 /// Appointments the save.
 /// </summary>
 /// <param name="oAppItem">The o app item.</param>
 public void AppointmentSave(Outlook._AppointmentItem oAppItem)
 {
     if (oAppItem == null)
     {
         throw new ArgumentNullException("oAppItem");
     }
     if (this.InvokeRequired)
     {
         VoidFunc <Outlook._AppointmentItem> func = AppointmentSave;
         this.Invoke(func, oAppItem);
     }
     else
     {
         oAppItem.Save();
     }
 }
Example #2
0
        public override bool AddAppointment()
        {
            try
            {
                Outlook._AppointmentItem appointmentItem = (Outlook._AppointmentItem)
                                                           OutlookApplication.CreateItem(Outlook.OlItemType.olAppointmentItem);

                appointmentItem.Subject = subject;
                appointmentItem.Start   = startDate;
                appointmentItem.End     = endDate;
                appointmentItem.Body    = String.Format(CultureConstants.DefaultCulture, "Added: {0}", DateTime.Now);

                appointmentItem.ReminderSet = reminder;

                appointmentItem.BusyStatus  = Outlook.OlBusyStatus.olBusy;
                appointmentItem.AllDayEvent = false;
                appointmentItem.Location    = String.Empty;

                if (alternateReminder)
                {
                    earlyReminder = new DateTime(startDate.Year, startDate.Month, startDate.Day, earlyReminder.Hour, earlyReminder.Minute, earlyReminder.Second);
                    lateReminder  = new DateTime(startDate.Year, startDate.Month, startDate.Day, lateReminder.Hour, lateReminder.Minute, lateReminder.Second);

                    DateTime dtReminder = WorkOutAlternateReminders();
                    // Subtract the reminder time from the appointment time.
                    TimeSpan timeSpan = appointmentItem.Start.Subtract(dtReminder);
                    appointmentItem.ReminderMinutesBeforeStart = Math.Abs((timeSpan.Hours * 60) + timeSpan.Minutes);
                    minutes = appointmentItem.ReminderMinutesBeforeStart;
                }

                if (reminder)
                {
                    appointmentItem.ReminderMinutesBeforeStart = minutes;
                }
                else
                {
                    appointmentItem.ReminderMinutesBeforeStart = 0;
                }

                appointmentItem.Save();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #3
0
        private void BtAgregar_Click(object sender, EventArgs e)
        {
            {
                if (CapaEntidad.Boton.Btn)
                {
                    try
                    {
                        string rpta = "";
                        if (this.CbNombre.Text == string.Empty || this.DtFecha.Text == string.Empty || this.CbElectrico.Text == string.Empty)
                        {
                            MensajeError("Falta ingresar datos, Los datos con * son Obligatorios");
                        }
                        else
                        {
                            //System.IO.MemoryStream ms = new System.IO.MemoryStream();
                            //this.PbFolio.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                            //byte[] image = ms.GetBuffer();
                            FileStream pdf          = File.OpenRead(ruta);
                            byte[]     contenidoPdf = new byte[pdf.Length];
                            pdf.Read(contenidoPdf, 0, (int)pdf.Length);
                            pdf.Close();

                            rpta = NAgInspeccion.Editar(Convert.ToInt32(this.LbID.Text), Convert.ToInt16(this.CbNombre.SelectedValue),
                                                        Convert.ToInt32(this.CbElectrico.SelectedValue), Convert.ToDateTime(this.DtFecha.Value), contenidoPdf);

                            if (rpta.Equals("OK"))
                            {
                                this.MensajeOk("Se Modificó el registro correctamente");
                            }

                            else
                            {
                                this.MensajeError(rpta);
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message + ex.StackTrace);
                    }
                }
                else
                {
                    try
                    {
                        string rpta = "";
                        if (this.CbNombre.Text == string.Empty || this.DtFecha.Text == string.Empty || this.CbElectrico.Text == string.Empty)
                        {
                            MensajeError("Falta ingresar datos, Los datos con * son Obligatorios");
                        }
                        else
                        {
                            //System.IO.MemoryStream ms = new System.IO.MemoryStream();
                            ////System.IO.MemoryStream ms2 = new System.IO.MemoryStream();
                            //this.PbFolio.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                            FileStream pdf          = File.OpenRead(ruta);
                            byte[]     contenidoPdf = new byte[pdf.Length];
                            pdf.Read(contenidoPdf, 0, (int)pdf.Length);
                            pdf.Close();
                            //byte[] image = ms.GetBuffer();

                            rpta = NAgInspeccion.Agregar(Convert.ToInt16(this.CbNombre.SelectedValue),
                                                         Convert.ToInt32(this.CbElectrico.SelectedValue), Convert.ToDateTime(this.DtFecha.Value), contenidoPdf);

                            if (this.CkOutlook.Checked == true)
                            {
                                // usar el objeto de outlook para crear el recordatorio
                                Outlook._Application     App = (Outlook._Application) new Outlook.Application();
                                Outlook._AppointmentItem apt = (Outlook._AppointmentItem)
                                                               App.CreateItem(Outlook.OlItemType.olAppointmentItem);
                                // algunas propiedades
                                apt.Subject = "Inspeccion obra" + this.CbNombre.Text;
                                apt.Body    = "reminderComment";
                                apt.Start   = this.DtFecha.Value;
                                apt.End     = this.DtFecha.Value.AddHours(6);
                                apt.ReminderMinutesBeforeStart = 1;
                                apt.BusyStatus  = Outlook.OlBusyStatus.olTentative;
                                apt.AllDayEvent = false;
                                apt.Save();
                            }
                            if (rpta.Equals("OK"))
                            {
                                this.MensajeOk("Se Agregó el registro correctamente");
                            }
                            else
                            {
                                this.MensajeError(rpta);
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message + ex.StackTrace);
                    }
                }
            }
        }