Esempio n. 1
0
        public IEnumerable <ValidHourEntry> SelValidHourEntries()
        {
            int intRC = 0;

            objValidHourEntries = new List <ValidHourEntry>();

            IParameterFactory objParams = new ValidHourEntryParameterFactory();

            System.Data.SqlClient.SqlCommand objCmd = new SqlCommand("pSelValidHours", new ADOConnectionFactory().Connection);
            objCmd.CommandType = CommandType.StoredProcedure;

            objCmd.Parameters.Add(objParams.Parmeters["RC"]);

            try
            {
                objCmd.Connection.Open();
                System.Data.SqlClient.SqlDataReader objDR = objCmd.ExecuteReader();
                while (objDR.Read())
                {
                    ValidHourEntry objVHE = new ValidHourEntry();
                    objVHE.TimePeriodID = (int)objDR["TimePeriodID"];
                    objVHE.TimePeriod   = (string)objDR["TimePeriod"];
                    ((List <ValidHourEntry>)objValidHourEntries).Add(objVHE);
                }
                objDR.Close();
                intRC = (int)objParams.Parmeters["RC"].Value;
                if (intRC < 0)
                {
                    throw new Exception("Error reported in Stored Procedure: " + objParams.Parmeters["RC"].Value.ToString());
                }
                objCmd.Connection.Close();
            }
            catch (Exception) { throw; }
            return(objValidHourEntries);
        }
Esempio n. 2
0
        public IEnumerable <ThisYearsDate> SelThisYearsDates()
        {
            int intRC = 0;

            objThisYearsDates = new List <ThisYearsDate>();

            IParameterFactory objParams = new ValidHourEntryParameterFactory();

            System.Data.SqlClient.SqlCommand objCmd = new SqlCommand("pSelThisYearsDates", new ADOConnectionFactory().Connection);
            objCmd.CommandType = CommandType.StoredProcedure;

            objCmd.Parameters.Add(objParams.Parmeters["RC"]);
            try
            {
                objCmd.Connection.Open();
                System.Data.SqlClient.SqlDataReader objDR = objCmd.ExecuteReader();
                while (objDR.Read())
                {
                    ThisYearsDate objTYD = new ThisYearsDate();
                    objTYD.DateID   = (int)objDR["DateID"];
                    objTYD.DateName = (string)objDR["DateName"];
                    ((List <ThisYearsDate>)objThisYearsDates).Add(objTYD);
                }

                objDR.Close(); //You cannot get the return value if the reader is not closed!
                intRC = (int)objParams.Parmeters["RC"].Value;
                if (intRC < 0)
                {
                    throw new Exception("Error reported in Stored Procedure: " + objParams.Parmeters["RC"].Value.ToString());
                }
                objCmd.Connection.Close();
            }
            catch (Exception) { throw; }
            return(objThisYearsDates);
        }
Esempio n. 3
0
        public IEnumerable<ValidHourEntry> SelValidHourEntries()
        {
            //Set up the variables
            int intRC = 0;
            SqlDataReader dr;
            List<ValidHourEntry> retVal = new List<ValidHourEntry>();

            //Set up the parameters using my custom parameter factory
            IParameterFactory objParams = new ValidHourEntryParameterFactory();

            try
            {
                using (SqlConnection sqlConnection = new ADOConnectionFactory().Connection)
                {
                    sqlConnection.Open();
                    using (SqlCommand sqlCommand = new SqlCommand())
                    {

                        sqlCommand.Connection = sqlConnection;

                        sqlCommand.Parameters.Add((objParams.Parameters["RC"]));

                        //call stored procedure to insert record
                        sqlCommand.CommandType = CommandType.StoredProcedure;
                        sqlCommand.CommandText = "pSelValidHours";

                        dr = sqlCommand.ExecuteReader();

                        while (dr.Read())
                        {
                            ValidHourEntry vhe = new ValidHourEntry();
                            vhe.TimePeriodID = (int)dr["TimePeriodID"];
                            vhe.TimePeriod = (string)dr["TimePeriod"];
                            retVal.Add(vhe);
                        }
                        dr.Close();

                        //check the return code for errors
                        intRC = (int)objParams.Parameters["RC"].Value;
                        if (intRC < 0)
                        {
                            throw new Exception("Error reported in Stored Procedure: " + objParams.Parameters["RC"].Value.ToString());
                        }

                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return retVal;
        }
Esempio n. 4
0
        public IEnumerable<ValidHourEntry> SelValidHourEntries()
        {
            int intRC = 0;
            objValidHourEntries = new List<ValidHourEntry>();

            IParameterFactory objParams = new ValidHourEntryParameterFactory();
            System.Data.SqlClient.SqlCommand objCmd = new SqlCommand("pSelValidHours", new ADOConnectionFactory().Connection);
            objCmd.CommandType = CommandType.StoredProcedure;

            objCmd.Parameters.Add(objParams.Parmeters["RC"]);
            try
            {
                objCmd.Connection.Open();
                System.Data.SqlClient.SqlDataReader objDR = objCmd.ExecuteReader();
                while (objDR.Read())
                {
                    ValidHourEntry objVHE = new ValidHourEntry();
                    objVHE.TimePeriodID = (int)objDR["TimePeriodID"];
                    objVHE.TimePeriod = (string)objDR["TimePeriod"];
                    ((List<ValidHourEntry>)objValidHourEntries).Add(objVHE);
                }

                objDR.Close(); //You cannot get the return value if the reader is not closed!
                intRC = (int)objParams.Parmeters["RC"].Value;
                if (intRC < 0)
                { throw new Exception("Error reported in Stored Procedure: " + objParams.Parmeters["RC"].Value.ToString()); }
                objCmd.Connection.Close();
            }
            catch (Exception) { throw; }
            return objValidHourEntries;
        }