Beispiel #1
0
        public void ABCDIAS(char Op, Rut.DIAS DIAS)
        {
            const string querySql = "Rut.prDIAS";
            int          IntReturn;

            try
            {
                using (SqlConnection connection = _objPersistencia.GetSqlConnection())
                {
                    connection.Open();

                    using (SqlCommand sqlCmnd = _objPersistencia.GetSqlCommand(connection, querySql, CommandType.StoredProcedure))
                    {
                        sqlCmnd.Parameters.AddWithValue("@Op", Op);
                        sqlCmnd.Parameters.AddWithValue("@IdDia", DIAS.IdDia);
                        sqlCmnd.Parameters.AddWithValue("@Dia", DIAS.Dia);

                        // Ejecucion del sqlCommand
                        using (SqlDataReader reader = sqlCmnd.ExecuteReader())
                        {
                            if (!reader.Read())
                            {
                                throw new Exception("La ejecución del Store Procedure no arrojó ningun dato");
                            }

                            // Verificamos el resultado de la ejecucion de sp 0 = correcto y 1 existe algun error
                            IntReturn = (int)reader["Result"];

                            if (IntReturn == 1)
                            {
                                throw new Exception(reader["MensajeError"].ToString());
                            }

                            reader.Close();
                        }

                        connection.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"{ex.Message} \n\nSP:  {querySql}");
            }
        }
Beispiel #2
0
 public void ABCDIAS(char Op, Rut.DIAS DIAS)
 {
     _objAdRutas.ABCDIAS(Op, DIAS);
 }