private void btnAgregarExc_Click(object sender, EventArgs e) { FechaExcepcion fechaExcepcion = new FechaExcepcion(dpExcepcion.Value); List <FechaExcepcion> otras = listExcepciones.Items.Cast <FechaExcepcion>().ToList(); if (otras.Count(d => fechaExcepcion.Equals(d)) > 0) { MensajePorPantalla.MensajeError(this, "No se puede cargar esa fecha porque ya se encuentra cargada"); } else { List <int> diasSemanaElegidos = listCronograma.Items.Cast <DiaSemana>().Select(d => d.Id).ToList(); if (diasSemanaElegidos.Count(d => d == (int)fechaExcepcion.Dia.DayOfWeek) == 0) { MensajePorPantalla.MensajeError(this, "Está intentando cargar una excepción a un día que no tiene horas cargadas"); } else { listExcepciones.Items.Add(fechaExcepcion); } } }
public decimal CrearExcepcion(FechaExcepcion exc) { IList <SqlParameter> parametros = new List <SqlParameter>(); SqlParameter pIdAgenda = new SqlParameter("@p_id_agenda", System.Data.SqlDbType.Decimal, 18, "p_id_agenda"); pIdAgenda.Value = exc.IdAgenda; parametros.Add(pIdAgenda); SqlParameter pDia = new SqlParameter("@p_dia", System.Data.SqlDbType.DateTime, 8, "p_dia"); pDia.Value = exc.Dia.Date; parametros.Add(pDia); SqlParameter pIdDiaExcepcion = new SqlParameter("@p_id_dia_excepcion", System.Data.SqlDbType.Decimal, 18, "p_id_dia_excepcion"); pIdDiaExcepcion.Direction = System.Data.ParameterDirection.Output; parametros.Add(pIdDiaExcepcion); _connector.RealizarConsultaAlmacenada("[TOP_4].[sp_Dia_Agenda_Excepcion_insert]", parametros); return((decimal)pIdDiaExcepcion.Value); }