Esempio n. 1
0
 private void SetReaderToObject(ref ModificationClass objModificationClass, ref SqlDataReader result)
 {
     if (result.HasRows)
     {
         objModificationClass.ModificationClassID          = (int)result.GetValue(result.GetOrdinal("ModificationClassID"));
         objModificationClass.ModificationClassName        = result.GetValue(result.GetOrdinal("ModificationClassName")).ToString();
         objModificationClass.ModificationClassDescription = result.GetValue(result.GetOrdinal("ModificationClassDescription")).ToString();
     }
 }
Esempio n. 2
0
        private List <ModificationClass> GetModificationClassList(string strSprocName, string strWhere, string strOrderBy)
        {
            List <ModificationClass> ModificationClasss = new List <ModificationClass>();

            SqlDataReader      result;
            DatabaseConnection dbconn     = new DatabaseConnection();
            SqlCommand         command    = new SqlCommand();
            SqlConnection      connection = new SqlConnection(dbconn.SQLSEVERConnString);

            try
            {
                connection.Open();
                command.Connection  = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = strSprocName;
                command.Parameters.Add(dbconn.GenerateParameterObj("@strWhere", SqlDbType.VarChar, strWhere, 1000));
                command.Parameters.Add(dbconn.GenerateParameterObj("@strOrderBy", SqlDbType.VarChar, strOrderBy, 1000));
                result = command.ExecuteReader();

                while (result.Read())
                {
                    ModificationClass objModificationClass = new ModificationClass();
                    SetReaderToObject(ref objModificationClass, ref result);
                    ModificationClasss.Add(objModificationClass);
                }
            }
            catch
            {
                Exception e = new Exception();
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(ModificationClasss);
        }