Exemplo n.º 1
0
        private void agregarFechas()
        {
            DateTime fe_inicial;
            DateTime fe_final;

            if (!dtpInicial.SelectedDate.HasValue | !dtpFinal.SelectedDate.HasValue)
            {
                UtilMensajes.MensajeResultadoDB(rwmEvento, "Indique la fecha inicial y final del evento", E_TIPO_RESPUESTA_DB.WARNING, pCallBackFunction: null);
                return;
            }

            if (dtpFinal.SelectedDate.Value < dtpInicial.SelectedDate.Value)
            {
                UtilMensajes.MensajeResultadoDB(rwmEvento, "El rango de fechas del evento no es el correcto", E_TIPO_RESPUESTA_DB.WARNING, pCallBackFunction: null);
                return;
            }

            if (!dpFecha.SelectedDate.HasValue)
            {
                UtilMensajes.MensajeResultadoDB(rwmEvento, "Indique el dia para el calendario", E_TIPO_RESPUESTA_DB.WARNING, pCallBackFunction: null);
                return;
            }

            if (dpFecha.SelectedDate.Value <dtpInicial.SelectedDate.Value | dpFecha.SelectedDate.Value> dtpFinal.SelectedDate.Value)
            {
                UtilMensajes.MensajeResultadoDB(rwmEvento, "La fecha que quiere agregar no está dentro de la fecha del evento", E_TIPO_RESPUESTA_DB.WARNING, pCallBackFunction: null);
                return;
            }

            if (!tpHoraInicial.SelectedDate.HasValue | !tpHorafinal.SelectedDate.HasValue)
            {
                UtilMensajes.MensajeResultadoDB(rwmEvento, "Indique la hora inicial y final del calendario del evento", E_TIPO_RESPUESTA_DB.WARNING, pCallBackFunction: null);
                return;
            }

            if (tpHorafinal.SelectedDate.Value < tpHoraInicial.SelectedDate.Value)
            {
                UtilMensajes.MensajeResultadoDB(rwmEvento, "El rango de horas no es el correcto", E_TIPO_RESPUESTA_DB.WARNING, pCallBackFunction: null);
                return;
            }

            fe_inicial = new DateTime(dpFecha.SelectedDate.Value.Year, dpFecha.SelectedDate.Value.Month, dpFecha.SelectedDate.Value.Day, tpHoraInicial.SelectedTime.Value.Hours, tpHoraInicial.SelectedTime.Value.Minutes, tpHoraInicial.SelectedTime.Value.Seconds);
            fe_final   = new DateTime(dpFecha.SelectedDate.Value.Year, dpFecha.SelectedDate.Value.Month, dpFecha.SelectedDate.Value.Day, tpHorafinal.SelectedTime.Value.Hours, tpHorafinal.SelectedTime.Value.Minutes, tpHorafinal.SelectedTime.Value.Seconds);

            if (FechasEventos.Count > 0)
            {
                var item = FechasEventos.Where(t => ((fe_inicial > t.FE_INICIAL & fe_inicial < t.FE_FINAL) | (fe_final > t.FE_INICIAL & fe_final < t.FE_FINAL))).FirstOrDefault();

                if (item != null)
                {
                    UtilMensajes.MensajeResultadoDB(rwmEvento, "Ya está agregado el día y hora al calendario del evento", E_TIPO_RESPUESTA_DB.WARNING, pCallBackFunction: null);
                    return;
                }
            }

            if (txtHoras.Text == "")
            {
                UtilMensajes.MensajeResultadoDB(rwmEvento, "Indique las horas efectivas del día", E_TIPO_RESPUESTA_DB.WARNING, pCallBackFunction: null);
                return;
            }

            E_EVENTO_CALENDARIO fechas = new E_EVENTO_CALENDARIO();

            fechas.ID_EVENTO_CALENDARIO = -1;
            fechas.FE_FINAL             = fe_final;
            fechas.FE_INICIAL           = fe_inicial;
            fechas.NO_HORAS             = byte.Parse(txtHoras.Text);


            dpFecha.SelectedDate       = null;
            tpHorafinal.SelectedDate   = null;
            tpHoraInicial.SelectedDate = null;
            txtHoras.Text = "";

            FechasEventos.Add(fechas);
            rgCalendario.Rebind();
        }
Exemplo n.º 2
0
 private void eliminarFechaCalendario(int index)
 {
     FechasEventos.RemoveAt(index);
 }