Exemplo n.º 1
0
        public IList<MakesInfo> GetMakes()
        {
            //Decalaring MakesInfo division object collection
            IList<MakesInfo> MakesInfoIList = new List<MakesInfo>();

            string spNameString = string.Empty;

            //Setting Connection
            //Global.INSTANCE_NAME = strCurrentConn;

            IDataReader MakesInfoDataReader = null;

            //Connect to the database
            Database dbDatabase = DatabaseFactory.CreateDatabase(Global.INSTANCE_NAME);

            //Assign stored procedure name

            spNameString = "[USP_GetAllMakes]";
            DbCommand dbCommand = null;

            try
            {
                //Set stored procedure to the command object
                dbCommand = dbDatabase.GetStoredProcCommand(spNameString);

                dbDatabase.AddInParameter(dbCommand, "@makeID", DbType.Int64, 0);

                //Executing stored procedure
                MakesInfoDataReader = dbDatabase.ExecuteReader(dbCommand);

                while (MakesInfoDataReader.Read())
                {
                    //Assign values to the MakesInfo object list
                    MakesInfo ObjMakesInfo_Info = new MakesInfo();
                    AssignMakesInfoList(MakesInfoDataReader, ObjMakesInfo_Info);
                    MakesInfoIList.Add(ObjMakesInfo_Info);
                }
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, Global.EXCEPTION_POLICY);

                if (rethrow)
                    throw;
            }
            finally
            {
                MakesInfoDataReader.Close();
            }

            return MakesInfoIList;
        }
Exemplo n.º 2
0
        private void AssignMakesInfoList(IDataReader MakesInfoDataReader, MakesInfo MakesInfo)
        {
            try
            {
                MakesInfo.MakeID = int.Parse(MakesInfoDataReader["makeID"].ToString());
                MakesInfo.Make = Convert.ToString(MakesInfoDataReader["make"]);
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, Global.EXCEPTION_POLICY);

            }
        }