Example #1
0
        /// <summary>
        /// Get Personal for Current Job
        /// </summary>
        /// <param name="jobId"></param>
        /// <param name="connection"></param>
        /// <returns></returns>
        public static List <JobPersonList> GetPersonalListForJobByJobId(Guid jobId, SqlConnection connection)
        {
            var list = new List <JobPersonList>();

            try
            {
                SqlDataReader rdr = null;
                connection.Open();
                // 1. create a command object identifying
                // the stored procedure
                SqlCommand cmd = new SqlCommand(
                    "JOB_JobPersonalByJobID", connection);

                // 2. set the command object so it knows
                // to execute a stored procedure
                cmd.CommandType = CommandType.StoredProcedure;

                // 3. add parameter to command, which
                // will be passed to the stored procedure
                SqlParameter parameter = new SqlParameter();
                parameter.SqlDbType     = SqlDbType.UniqueIdentifier;
                parameter.ParameterName = "@JobID";
                parameter.Value         = jobId;
                cmd.Parameters.Add(parameter);
                // execute the command
                rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    JobPersonList person = new JobPersonList
                                           (
                        new Guid(rdr.GetValue(0).ToString()),
                        new Guid(rdr.GetValue(1).ToString()),
                        rdr.GetValue(2).ToString(),
                        rdr.GetValue(3).ToString(),
                        rdr.GetValue(4).ToString(),
                        rdr.GetValue(5).ToString(),
                        Convert.ToBoolean(rdr.GetValue(6).ToString())
                                           );
                    // Add To list
                    list.Add(person);
                }
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }

            return(list);
        }
Example #2
0
        /// <summary>
        /// Get Personal for Current Job
        /// </summary>
        /// <param name="jobId"></param>
        /// <param name="connection"></param>
        /// <returns></returns>
        public static List<JobPersonList> GetPersonalListForJobByJobId(Guid jobId, SqlConnection connection)
        {
            var list = new List<JobPersonList>();

            try
            {
                SqlDataReader rdr = null;
                connection.Open();
                // 1. create a command object identifying
                // the stored procedure
                SqlCommand cmd = new SqlCommand(
                    "JOB_JobPersonalByJobID", connection);

                // 2. set the command object so it knows
                // to execute a stored procedure
                cmd.CommandType = CommandType.StoredProcedure;

                // 3. add parameter to command, which
                // will be passed to the stored procedure
                SqlParameter parameter = new SqlParameter();
                parameter.SqlDbType = SqlDbType.UniqueIdentifier;
                parameter.ParameterName = "@JobID";
                parameter.Value = jobId;
                cmd.Parameters.Add(parameter);
                // execute the command
                rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {

                    JobPersonList person = new JobPersonList
                        (
                            new Guid(rdr.GetValue(0).ToString()),
                            new Guid(rdr.GetValue(1).ToString()),
                            rdr.GetValue(2).ToString(),
                            rdr.GetValue(3).ToString(),
                            rdr.GetValue(4).ToString(),
                            rdr.GetValue(5).ToString(),
                            Convert.ToBoolean(rdr.GetValue(6).ToString())
                        );
                    // Add To list
                    list.Add(person);
                }

            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }

            return list;
        }