コード例 #1
0
 protected void lnkcommandevent_Click(object sender, EventArgs e)
 {
     try
     {
         string     motivo                 = hdfmotivos.Value;
         LinkButton lnk                    = sender as LinkButton;
         string     comand                 = lnk.CommandName.ToLower();
         string     usuario                = Session["usuario"] as string;
         int        id_recordatorio        = Convert.ToInt32(lnk.CommandArgument);
         datos.Model.recordatorios entidad = new datos.Model.recordatorios();
         entidad.id_recordatorio     = id_recordatorio;
         entidad.comentarios_borrado = motivo;
         entidad.usuario_borrado     = usuario;
         RecordatoriosCOM recordatorio = new RecordatoriosCOM();
         string           vmensaje     = "";
         DataTable        dt_days      = recordatorio.Get(usuario.ToUpper());
         DataView         dv           = dt_days.DefaultView;
         dv.RowFilter = "id_recordatorio = " + id_recordatorio + "";
         if (dv.ToTable().Rows.Count > 0)
         {
             DataRow row           = dv.ToTable().Rows[0];
             bool    isAppointment = Convert.ToBoolean(row["appointment"]);
             if (isAppointment)
             {
                 String    password     = Session["contraseña"] as string;
                 string    username     = Session["usuario"] as string;
                 string    mail         = Session["mail"] as string;
                 string    mail_user    = username + mail.Replace(mail.Split('@')[0], "");
                 string    id           = row["key"].ToString();
                 EWSHelper appointments = new EWSHelper();
                 vmensaje = comand == "aceptar" ? appointments.AcceptAppointment(mail_user, password, id) : appointments.DeclineAppointment(mail_user, password, id, motivo);
                 if (comand == "rechazar" && vmensaje == "")
                 {
                     vmensaje = recordatorio.Eliminar(entidad);
                 }
             }
         }
         if (vmensaje == "")
         {
             ModalClose("#myModal");
             usuario = Session["usuario"] as string;
             ListaRecordatorios(usuario, Convert.ToDateTime(hdffecha.Value));
             LimpiarControles();
             IniciarCalendario();
             Toast.Success("Recordatorio respondido correctamente.", "Mensaje del sistema", this);
         }
         else
         {
             Toast.Error("Error al responder recordatorio: " + vmensaje, this);
         }
     }
     catch (Exception ex)
     {
         Toast.Error("Error al responder recordatorio: " + ex.Message, this);
     }
     finally {
         load_items.Style["display"] = "none";
     }
 }
コード例 #2
0
        private void Eliminar(int id_recordatorio, string motivo, string usuario)
        {
            try
            {
                datos.Model.recordatorios entidad = new datos.Model.recordatorios();
                entidad.id_recordatorio     = id_recordatorio;
                entidad.comentarios_borrado = motivo;
                entidad.usuario_borrado     = usuario;
                RecordatoriosCOM recordatorio = new RecordatoriosCOM();
                string           vmensaje     = "";
                DataTable        dt_days      = recordatorio.Get(usuario.ToUpper());
                DataView         dv           = dt_days.DefaultView;
                dv.RowFilter = "id_recordatorio = " + id_recordatorio + "";
                if (dv.ToTable().Rows.Count > 0)
                {
                    DataRow row           = dv.ToTable().Rows[0];
                    bool    isAppointment = Convert.ToBoolean(row["appointment"]);
                    if (isAppointment)
                    {
                        String    password     = Session["contraseña"] as string;
                        string    username     = Session["usuario"] as string;
                        string    mail         = Session["mail"] as string;
                        string    mail_user    = username + mail.Replace(mail.Split('@')[0], "");
                        string    id           = row["key"].ToString();
                        EWSHelper appointments = new EWSHelper();
                        vmensaje = appointments.CancelAppointment(mail_user, password, id, motivo);
                    }
                }
                if (vmensaje == "")
                {
                    vmensaje = recordatorio.Eliminar(entidad);
                }

                if (vmensaje == "")
                {
                    ModalClose("#myModal");
                    usuario = Session["usuario"] as string;
                    ListaRecordatorios(usuario, Convert.ToDateTime(hdffecha.Value));
                    LimpiarControles();
                    IniciarCalendario();
                    Toast.Success("Recordatorio eliminado correctamente.", "Mensaje del sistema", this);
                }
                else
                {
                    Toast.Error("Error al eliminar recordatorio: " + vmensaje, this);
                }
            }
            catch (Exception ex)
            {
                Toast.Error("Error al eliminar recordatorio: " + ex.Message, this);
            }
        }
コード例 #3
0
 public static String GetRecords(string user)
 {
     try
     {
         RecordatoriosCOM recordatorios = new RecordatoriosCOM();
         DataTable        dt            = recordatorios.Get(user);
         List <Event>     eventos       = new List <Event>();
         foreach (DataRow row in dt.Rows)
         {
             row["fecha_end"] = row["fecha_end"] == DBNull.Value ? Convert.ToDateTime(row["fecha"]).AddMinutes(30) : row["fecha_end"];
             string color          = Convert.ToBoolean(row["appointment"]) ? "#1565c0 " : "#f56954";
             string day_           = Convert.ToDateTime(row["fecha"]).Day.ToString();
             string month_         = (Convert.ToDateTime(row["fecha"]).Month).ToString();
             string year_          = Convert.ToDateTime(row["fecha"]).Year.ToString();
             string minutes_       = (Convert.ToDateTime(row["fecha"]).Minute).ToString();
             string minutes_finish = (Convert.ToDateTime(row["fecha_end"]).Minute).ToString();
             string hours          = Convert.ToDateTime(row["fecha"]).Hour.ToString();
             string hours_         = Convert.ToDateTime(row["fecha_end"]).Hour.ToString();
             month_         = month_.Length == 1 ? "0" + month_ : month_;
             day_           = day_.Length == 1 ? "0" + day_ : day_;
             hours          = hours.Length == 1 ? "0" + hours : hours;
             minutes_       = minutes_.Length == 1 ? "0" + minutes_ : minutes_;
             minutes_finish = minutes_finish.Length == 1 ? "0" + minutes_finish : minutes_finish;
             eventos.Add(new Event(
                             row["titulo"].ToString(),
                             year_ + "-" + month_ + "-" + day_ + "T" + hours + ":" + minutes_ + ":00",
                             year_ + "-" + month_ + "-" + day_ + "T" + hours_ + ":" + minutes_finish + ":00",
                             color,
                             color,
                             row["organizer"] == null ? "" : row["organizer"].ToString(),
                             row["location"] == null ? "" : row["location"].ToString(),
                             row["descripcion"] == null ? "" : row["descripcion"].ToString(),
                             row["organizer_address"] == null ? "" : row["organizer_address"].ToString(),
                             Convert.ToBoolean(row["appointment"]),
                             Convert.ToDateTime(row["fecha"]).ToString("dddd dd MMMM, yyyy hh:mm tt", CultureInfo.CreateSpecificCulture("es-MX")),
                             Convert.ToDateTime(row["fecha_end"]).ToString("dddd dd MMMM, yyyy hh:mm tt", CultureInfo.CreateSpecificCulture("es-MX"))
                             ));
         }
         string ret = JsonConvert.SerializeObject(eventos);
         return(ret);
     }
     catch (Exception ex)
     {
         return(JsonConvert.SerializeObject(""));
     }
 }
コード例 #4
0
 protected void btnedit_Click(object sender, EventArgs e)
 {
     try
     {
         DateTime date_selected = Convert.ToDateTime(hdffecha.Value);
         string   usuario       = Session["usuario"] as string;
         txtid_recordatorio.Text = hdfid_rec.Value;
         ListaRecordatorios(usuario, date_selected);
         RecordatoriosCOM recordatorio = new RecordatoriosCOM();
         DataTable        dt_days      = recordatorio.Get(usuario.ToUpper());
         DataView         dv           = dt_days.DefaultView;
         int id_recordatorio           = Convert.ToInt32(hdfid_rec.Value == "" ? "0" : hdfid_rec.Value);
         dv.RowFilter = "id_recordatorio = " + id_recordatorio + "";
         if (dv.ToTable().Rows.Count > 0)
         {
             DataRow row = dv.ToTable().Rows[0];
             rtxttitulo.Text          = row["titulo"].ToString();
             rtxtdescripcion.Text     = row["descripcion"].ToString().Replace(Environment.NewLine, " ");
             txtfecharec.SelectedDate = Convert.ToDateTime(row["fecha"]);
             IniciarCalendario();
             Boolean isAppointment = Convert.ToBoolean(row["appointment"]);
             div_organizador.Visible = isAppointment;
             div_fecha_fin.Visible   = isAppointment;
             if (isAppointment)
             {
                 rtxtlugar.Text            = row["location"].ToString();
                 txtfechafin.SelectedDate  = Convert.ToDateTime(row["fecha_end"]);
                 rtxtorganizador.Text      = row["organizer"].ToString();
                 rtxtcorreorganizador.Text = row["organizer_address"].ToString();
             }
             ModalShow("#myModal");
         }
         else
         {
             Toast.Error("Error al cargar recordatorio: No se encuentra ningun recordatorio", this);
         }
     }
     catch (Exception ex)
     {
         Toast.Error("Error al cargar recordatorio: " + ex.Message, this);
     }
 }
コード例 #5
0
        public StringBuilder InicializarCalendario()
        {
            try
            {
                string           usuario       = Session["usuario"] as string;
                DateTime         fecha         = Convert.ToDateTime(txtfecha.Text);
                RecordatoriosCOM recordatorios = new RecordatoriosCOM();
                DataTable        dt            = recordatorios.Get(usuario);
                StringBuilder    sb            = new StringBuilder();
                string           day           = fecha.Day.ToString();
                string           month         = fecha.Month.ToString();
                string           year          = fecha.Year.ToString();
                month = month.Length == 1 ? "0" + month : month;
                day   = day.Length == 1 ? "0" + day : day;
                if (dt.Rows.Count > 0)
                {
                    string eventos = "";
                    foreach (DataRow row in dt.Rows)
                    {
                        row["fecha_end"] = row["fecha_end"] == DBNull.Value ? Convert.ToDateTime(row["fecha"]).AddMinutes(30) : row["fecha_end"];
                        string color          = Convert.ToBoolean(row["appointment"]) ? "#1565c0 " : "#f56954";
                        string day_           = Convert.ToDateTime(row["fecha"]).Day.ToString();
                        string month_         = (Convert.ToDateTime(row["fecha"]).Month).ToString();
                        string year_          = Convert.ToDateTime(row["fecha"]).Year.ToString();
                        string minutes_       = (Convert.ToDateTime(row["fecha"]).Minute).ToString();
                        string minutes_finish = (Convert.ToDateTime(row["fecha_end"]).Minute).ToString();
                        string hours          = Convert.ToDateTime(row["fecha"]).Hour.ToString();
                        string hours_         = Convert.ToDateTime(row["fecha_end"]).Hour.ToString();
                        month_         = month_.Length == 1 ? "0" + month_ : month_;
                        day_           = day_.Length == 1 ? "0" + day_ : day_;
                        hours          = hours.Length == 1 ? "0" + hours : hours;
                        minutes_       = minutes_.Length == 1 ? "0" + minutes_ : minutes_;
                        minutes_finish = minutes_finish.Length == 1 ? "0" + minutes_finish : minutes_finish;
                        eventos        = eventos + "  {title: '" + row["titulo"].ToString() + "'," +
                                         "start: '" + year_ + "-" + month_ + "-" + day_ + "T" + hours + ":" + minutes_ + ":00'," +
                                         "end:'" + year_ + "-" + month_ + "-" + day_ + "T" + hours + ":" + minutes_finish + ":00'," +
                                         "backgroundColor:'" + color + "'," +
                                         "borderColor: '" + color + "'," +
                                         "allday:false," +
                                         "id:" + row["id_recordatorio"].ToString() +
                                         "},";
                    }
                    eventos = eventos.Substring(0, eventos.Length - 1);

                    sb.Append("<script type='text/javascript'>");
                    sb.Append(""
                              + " $(function () {" +
                              " $('#calendar').fullCalendar({" +
                              "     locale: 'es'," +
                              "     dayClick: function(date, jsEvent, view) {" +
                              "         $('#" + hdffecha.ClientID + "').val(date.format());" +
                              "         document.getElementById('" + btncalendar.ClientID + "').click();" +
                              "     }," +
                              "     eventClick: function(calEvent, jsEvent, view) {" +
                              "         $('#" + hdffecha.ClientID + "').val(calEvent.start.format());" +
                              "         return EditRecordatorios(calEvent.id); }," +
                              "     header: {" +
                              "         left: 'prev,next today'," +
                              "         center: 'title'," +
                              "         right: 'month,agendaWeek,agendaDay'" +
                              "     }," +
                              "     buttonText: {" +
                              "         today: 'Hoy'," +
                              "         month: 'Mes'," +
                              "         week: 'Sem'," +
                              "         day: 'Dia'" +
                              "     }," +
                              "     events: [" + eventos + "]," +
                              "     editable: false," +
                              "     droppable: false" +
                              " });" +
                              " $('#calendar').fullCalendar('gotoDate', '" + year + "-" + month + "-" + day + "');" +
                              " });");
                    sb.Append("</script>");
                }
                else
                {
                    sb.Append("<script type='text/javascript'>");
                    sb.Append(""
                              + " $(function () {" +
                              " $('#calendar').fullCalendar({" +
                              "     locale: 'es'," +
                              "     dayClick: function(date, jsEvent, view) {" +
                              "         $('#" + hdffecha.ClientID + "').val(date.format());" +
                              "         document.getElementById('" + btncalendar.ClientID + "').click();" +
                              "     }," +
                              "     eventClick: function(calEvent, jsEvent, view) {" +
                              "         $('#" + hdffecha.ClientID + "').val(calEvent.start.format());" +
                              "         return EditRecordatorios(calEvent.id); }," +
                              "     header: {" +
                              "         left: 'prev,next today'," +
                              "         center: 'title'," +
                              "         right: 'month,agendaWeek,agendaDay'" +
                              "     }," +
                              "     buttonText: {" +
                              "         today: 'Hoy'," +
                              "         month: 'Mes'," +
                              "         week: 'Sem'," +
                              "         day: 'Dia'" +
                              "     }" +
                              " });" +
                              " $('#calendar').fullCalendar('gotoDate', '" + year + "-" + month + "-" + day + "');" +
                              " });");
                    sb.Append("</script>");
                }

                return(sb);
            }
            catch (Exception ex)
            {
                Toast.Error("Error al generar calendario: " + ex.Message, this);
                return(new StringBuilder());
            }
        }
コード例 #6
0
        public StringBuilder InicializarCalendario()
        {
            try
            {
                string           usuario       = Session["usuario"] as string;
                DateTime         fecha         = Convert.ToDateTime(DateTime.Now);
                RecordatoriosCOM recordatorios = new RecordatoriosCOM();
                DataTable        dt            = recordatorios.Get(usuario);
                string           eventos       = "";
                foreach (DataRow row in dt.Rows)
                {
                    row["fecha_end"] = row["fecha_end"] == DBNull.Value ? Convert.ToDateTime(row["fecha"]).AddMinutes(30) : row["fecha_end"];
                    string color          = Convert.ToBoolean(row["appointment"]) ? "#1565c0 " : "#f56954";
                    string day_           = Convert.ToDateTime(row["fecha"]).Day.ToString();
                    string month_         = (Convert.ToDateTime(row["fecha"]).Month).ToString();
                    string year_          = Convert.ToDateTime(row["fecha"]).Year.ToString();
                    string minutes_       = (Convert.ToDateTime(row["fecha"]).Minute).ToString();
                    string minutes_finish = (Convert.ToDateTime(row["fecha_end"]).Minute).ToString();
                    string hours          = Convert.ToDateTime(row["fecha"]).Hour.ToString();
                    string hours_         = Convert.ToDateTime(row["fecha_end"]).Hour.ToString();
                    month_         = month_.Length == 1 ? "0" + month_ : month_;
                    day_           = day_.Length == 1 ? "0" + day_ : day_;
                    hours          = hours.Length == 1 ? "0" + hours : hours;
                    minutes_       = minutes_.Length == 1 ? "0" + minutes_ : minutes_;
                    minutes_finish = minutes_finish.Length == 1 ? "0" + minutes_finish : minutes_finish;
                    eventos        = eventos +
                                     "{title: '" + row["titulo"].ToString() + "'," +
                                     "start: '" + year_ + "-" + month_ + "-" + day_ + "T" + hours + ":" + minutes_ + ":00'," +
                                     "end:'" + year_ + "-" + month_ + "-" + day_ + "T" + hours + ":" + minutes_finish + ":00'," +
                                     "backgroundColor:'" + color + "'," +
                                     "borderColor: '" + color + "'," +
                                     "allday:false," +
                                     "id:" + row["id_recordatorio"].ToString() + "," +
                                     "organizador:'" + (row["organizer"] == null ? "" : row["organizer"].ToString()) + "'," +
                                     "ubicacion:'" + (row["location"] == null ? "" : row["location"].ToString()) + "'," +
                                     "descripcion:'" + (row["descripcion"] == null ? "" : row["descripcion"].ToString().Replace(Environment.NewLine, " ")) + "'," +
                                     "organizador_mail:'" + (row["organizer_address"] == null ? "" : row["organizer_address"].ToString()) + "'," +
                                     "Isappointment:" + Convert.ToBoolean(row["appointment"]).ToString().ToLower() + "," +
                                     "start_:'" + Convert.ToDateTime(row["fecha"]).ToString("dddd dd MMMM, yyyy hh:mm tt", CultureInfo.CreateSpecificCulture("es-MX")) + "'," +
                                     "end_:'" + Convert.ToDateTime(row["fecha_end"]).ToString("dddd dd MMMM, yyyy hh:mm tt", CultureInfo.CreateSpecificCulture("es-MX")) + "'" +

                                     "},";
                }
                eventos = eventos.Length > 1 ? eventos.Substring(0, eventos.Length - 1) : eventos;
                string day   = fecha.Day.ToString();
                string month = fecha.Month.ToString();
                string year  = fecha.Year.ToString();
                month = month.Length == 1 ? "0" + month : month;
                day   = day.Length == 1 ? "0" + day : day;
                StringBuilder sb = new StringBuilder();
                sb.Append("<script type='text/javascript'>");
                sb.Append(""
                          + " $(function () {" +
                          " $('#calendar').fullCalendar({" +
                          "     locale: 'es',height: 300," +
                          "     header: {" +
                          "         left: 'prev,next today'," +
                          "         center: 'title'," +
                          "         right: 'month,agendaWeek,agendaDay'" +
                          "     }," +
                          "eventClick: function (calEvent, jsEvent, view) {" +
                          "      var Isappointment = calEvent.Isappointment;" +
                          "      $('#div_fecha_fin').hide();" +
                          "      $('#div_organizador').hide();" +
                          "      if (calEvent.Isappointment)" +
                          "      {                " +
                          "          $('#div_fecha_fin').show();" +
                          "          $('#div_organizador').show();" +
                          "          $('#ContentPlaceHolder1_rtxtlugar').val(calEvent.ubicacion);" +
                          "          $('#ContentPlaceHolder1_rtxtorganizador').val(calEvent.organizador);" +
                          "          $('#ContentPlaceHolder1_rtxtcorreorganizador').val(calEvent.organizador_mail);" +
                          "          $('#ContentPlaceHolder1_txtfechafin').val(calEvent.end_);" +
                          "      }" +
                          "      $('#ContentPlaceHolder1_txtfechainicio').val(calEvent.start_);" +
                          "      $('#ContentPlaceHolder1_rtxttitulo').val(calEvent.title);" +
                          "      $('#ContentPlaceHolder1_rtxtdescripcion').val(calEvent.descripcion);" +
                          "      ModalShow('#modal_evento');" +
                          "  }," +
                          "     buttonText: {" +
                          "         today: 'Hoy'," +
                          "         month: 'Mes'," +
                          "         week: 'Sem'," +
                          "         day: 'Dia'" +
                          "     }," +
                          "     events: [" + eventos + "]," +
                          "     editable: false," +
                          "     droppable: false" +
                          " });" +
                          " $('#calendar').fullCalendar('gotoDate', '" + year + "-" + month + "-" + day + "');" +
                          " });");
                sb.Append("</script>");
                return(sb);
            }
            catch (Exception ex)
            {
                Toast.Error("Error al generar calendario: " + ex.Message, this);
                return(new StringBuilder());
            }
        }