Exemplo n.º 1
0
        /// <summary>
        /// Update an entry in the EmployeePayRate table
        /// </summary>
        public static bool Update(EmployeePayRate employeePayRate)
        {
            bool result = false;

            SqlConnection cn = GetConnection();

            result = Update(cn, employeePayRate);
            FinishedWithConnection(cn);
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get an entry from the EmployeePayRate table
        /// </summary>
        public static EmployeePayRate Get(int id)
        {
            EmployeePayRate result = null;

            SqlConnection cn = GetConnection();

            result = Get(cn, id);
            FinishedWithConnection(cn);
            return(result);
        }
Exemplo n.º 3
0
        private static EmployeePayRate Get(SqlConnection cn, int id)
        {
            EmployeePayRate result = null;

            using (SqlCommand cmd = new SqlCommand("SELECT * FROM EmployeePayRate WHERE EmployeePayRateId=" + id, cn))
            {
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildEmployeePayRate(rdr);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        private static bool Update(SqlConnection cn, EmployeePayRate employeePayRate)
        {
            Int32 rowsAffected = 0;

            using (SqlCommand sqlCmd = cn.CreateCommand())
            {
                sqlCmd.CommandText = "UPDATE EmployeePayRate SET EmployeePayRateEmployeeId=@EmployeePayRateEmployeeId,EmployeePayRateEmployeeJobId=@EmployeePayRateEmployeeJobId,EmployeePayRateWage=@EmployeePayRateWage,EmployeePayRateOvertimeWage=@EmployeePayRateOvertimeWage WHERE EmployeePayRateId=@EmployeePayRateId";

                BuildSqlParameter(sqlCmd, "@EmployeePayRateId", SqlDbType.Int, employeePayRate.Id);
                BuildSqlParameter(sqlCmd, "@EmployeePayRateEmployeeId", SqlDbType.Int, employeePayRate.EmployeeId);
                BuildSqlParameter(sqlCmd, "@EmployeePayRateEmployeeJobId", SqlDbType.Int, employeePayRate.JobId);
                BuildSqlParameter(sqlCmd, "@EmployeePayRateWage", SqlDbType.Float, employeePayRate.Wage);
                BuildSqlParameter(sqlCmd, "@EmployeePayRateOvertimeWage", SqlDbType.Float, employeePayRate.OvertimeWage);

                rowsAffected = sqlCmd.ExecuteNonQuery();
            }
            return(rowsAffected != 0);
        }
Exemplo n.º 5
0
        public static EmployeePayRate GetEmployeePayRateForJob(int employeeId, int jobId)
        {
            EmployeePayRate result = null;
            SqlConnection   cn     = GetConnection();

            using (SqlCommand cmd = new SqlCommand(
                       "SELECT * FROM EmployeePayRate WHERE (EmployeePayRateEmployeeId="
                       + employeeId + " AND EmployeePayRateEmployeeJobId=" + jobId + ")", cn))
            {
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildEmployeePayRate(rdr);
                    }
                }
            }
            FinishedWithConnection(cn);
            return(result);
        }
Exemplo n.º 6
0
        public static EmployeePayRate Add(int employeeId, int jobId,
                                          double wage, double overtimeWage)
        {
            EmployeePayRate result = null;

            SqlConnection cn = GetConnection();

            using (SqlCommand sqlCmd = new SqlCommand("AddEmployeePayRate", cn))
            {
                sqlCmd.CommandType = CommandType.StoredProcedure;
                BuildSqlParameter(sqlCmd, "@EmployeePayRateEmployeeId", SqlDbType.Int, employeeId);
                BuildSqlParameter(sqlCmd, "@EmployeePayRateEmployeeJobId", SqlDbType.Int, jobId);
                BuildSqlParameter(sqlCmd, "@EmployeePayRateWage", SqlDbType.Float, wage);
                BuildSqlParameter(sqlCmd, "@EmployeePayRateOvertimeWage", SqlDbType.Float, overtimeWage);
                BuildSqlParameter(sqlCmd, "@EmployeePayRateId", SqlDbType.Int, ParameterDirection.ReturnValue);
                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    result = new EmployeePayRate(Convert.ToInt32(sqlCmd.Parameters["@EmployeePayRateId"].Value),
                                                 employeeId, jobId, wage, overtimeWage);
                }
            }
            FinishedWithConnection(cn);
            return(result);
        }