예제 #1
0
        public static void SaveException(ControlErroresModel aControlErroresModel)
        {
            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    //connection.Open();

                    //SqlTransaction sqlTran = connection.BeginTransaction();

                    //SqlCommand command = connection.CreateCommand();

                    //command.Transaction = sqlTran;

                    //command.Parameters.AddWithValue("@Usuario", aControlErroresModel.Usuario);
                    //command.Parameters.AddWithValue("@Fecha", aControlErroresModel.Fecha);
                    //command.Parameters.AddWithValue("@Componente", aControlErroresModel.Componente);
                    //command.Parameters.AddWithValue("@Descripcion", aControlErroresModel.Descripcion == null ? (object)DBNull.Value : aControlErroresModel.Descripcion);


                    //command.CommandType = CommandType.StoredProcedure;
                    //command.CommandText = "ControlErroresModelInsert";


                    //// Commit the transaction.
                    //sqlTran.Commit();

                    //connection.Close();
                    //connection.Dispose();
                }
            }
            catch (Exception)
            {
            }
        }
예제 #2
0
        /// <summary>
        /// Selects the Single object of ControlErroresModel table.
        /// </summary>
        public ControlErroresModel GetControlErroresModel(int aId)
        {
            ControlErroresModel ControlErroresModel = null;

            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlCommand command = connection.CreateCommand();

                    command.Parameters.AddWithValue("@Id", aId);


                    command.CommandType = CommandType.StoredProcedure;

                    command.CommandText = "ControlErroresModelSelect";

                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            int      Id          = (int)(reader["Id"]);
                            string   Usuario     = (string)(reader["Usuario"]);
                            DateTime Fecha       = (DateTime)(reader["Fecha"]);
                            string   Componente  = (string)(reader["Componente"]);
                            byte[]   Descripcion = (byte[])(reader["Descripcion"]);

                            ControlErroresModel = new ControlErroresModel
                            {
                                Id          = Id,
                                Usuario     = Usuario,
                                Fecha       = Fecha,
                                Componente  = Componente,
                                Descripcion = Descripcion,
                            };
                        }
                    }
                }

                return(ControlErroresModel);
            }
            catch (Exception)
            {
                return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// Updates a record to the ControlErroresModel table.
        /// returns True if value saved successfully else false
        /// Throw exception with message value EXISTS if the data is duplicate
        /// </summary>
        public bool Update(ControlErroresModel aControlErroresModel)
        {
            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlTransaction sqlTran = connection.BeginTransaction();

                    SqlCommand command = connection.CreateCommand();

                    command.Transaction = sqlTran;

                    command.Parameters.AddWithValue("@Id", aControlErroresModel.Id);
                    command.Parameters.AddWithValue("@Usuario", aControlErroresModel.Usuario);
                    command.Parameters.AddWithValue("@Fecha", aControlErroresModel.Fecha);
                    command.Parameters.AddWithValue("@Componente", aControlErroresModel.Componente);
                    command.Parameters.AddWithValue("@Descripcion", aControlErroresModel.Descripcion == null ? (object)DBNull.Value : aControlErroresModel.Descripcion);


                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "ControlErroresModelUpdate";

                    int afectados = command.ExecuteNonQuery();

                    // Commit the transaction.
                    sqlTran.Commit();

                    connection.Close();
                    connection.Dispose();

                    if (afectados > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }