Exemplo n.º 1
0
        public BE.Feriado Obtener(DateTime fecha)
        {
            BE.Feriado beFeriado = null;
            try
            {
                string sp = "SpTbFeriadoObtener";

                using (SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal))
                {
                    cnn.Open();

                    SqlCommand cmd = new SqlCommand(sp, cnn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@FECHA", fecha));

                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader.Read())
                    {
                        beFeriado = new BE.Feriado();

                        beFeriado.Fecha   = DateTime.Parse(reader["Fecha"].ToString());
                        beFeriado.Motivo  = reader["Motivo"].ToString();
                        beFeriado.Festivo = bool.Parse(reader["Festivo"].ToString());
                        beFeriado.Activo  = bool.Parse(reader["Activo"].ToString());
                    }
                }

                return(beFeriado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public int Actualizar(BE.Feriado beFeriado)
        {
            try
            {
                int    rowsAffected = 0;
                string sp           = "SpTbFeriadoActualizar";

                using (SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal))
                {
                    cnn.Open();

                    SqlCommand cmd = new SqlCommand(sp, cnn);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add(new SqlParameter("@Fecha", beFeriado.Fecha));
                    cmd.Parameters.Add(new SqlParameter("@Festivo", beFeriado.Festivo));
                    cmd.Parameters.Add(new SqlParameter("@Motivo", beFeriado.Motivo));
                    cmd.Parameters.Add(new SqlParameter("@Activo", beFeriado.Activo));

                    rowsAffected = cmd.ExecuteNonQuery();
                }

                return(rowsAffected);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public List <BE.Feriado> ListarMes(int anho, int mes)
        {
            List <BE.Feriado> lstFeriado = new List <BE.Feriado>();

            try
            {
                string sp = "SpTbFeriadoListarMes";

                using (SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal))
                {
                    cnn.Open();

                    SqlCommand cmd = new SqlCommand(sp, cnn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@ANHO", anho));
                    cmd.Parameters.Add(new SqlParameter("@MES", mes));

                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        var beFeriado = new BE.Feriado();

                        beFeriado.Fecha   = DateTime.Parse(reader["Fecha"].ToString());
                        beFeriado.Motivo  = reader["Motivo"].ToString();
                        beFeriado.Festivo = bool.Parse(reader["Festivo"].ToString());
                        beFeriado.Activo  = bool.Parse(reader["Activo"].ToString());

                        lstFeriado.Add(beFeriado);
                    }
                }

                return(lstFeriado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }