예제 #1
0
        public IList<BodyInfo> GetBodys()
        {
            //Decalaring MakesInfo division object collection
            IList<BodyInfo> MakesInfoIList = new List<BodyInfo>();

            string spNameString = string.Empty;

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

            IDataReader BodysInfoDataReader = null;

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

            //Assign stored procedure name

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

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

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

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

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

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

            return MakesInfoIList;
        }
예제 #2
0
        private void AssignBodysInfoList(IDataReader BodysInfoDataReader, BodyInfo ObjBodysInfo_Info)
        {
            try
            {
                ObjBodysInfo_Info.BodyTypeID = int.Parse(BodysInfoDataReader["bodyTypeID"].ToString());
                ObjBodysInfo_Info.BodyType = Convert.ToString(BodysInfoDataReader["bodyType"]);
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, Global.EXCEPTION_POLICY);

            }
        }