コード例 #1
0
        public IList <ShiftType> GetAllShiftType()
        {
            List <ShiftType> allShiftTypes = new List <ShiftType>();

            using (SqlConnection con = GetConnection())
            {
                con.Open();

                SqlCommand command = new SqlCommand("GetAllShiftTypes", con);
                command.CommandType = CommandType.StoredProcedure;

                var results = command.ExecuteReader();

                if (results.HasRows)
                {
                    ShiftType shiftType;
                    int       tempInt;

                    while (results.Read())
                    {
                        shiftType = new ShiftType();

                        shiftType.Name = results["Name"].ToString();

                        int.TryParse(results["ShiftID"].ToString(), out tempInt);
                        shiftType.ShiftID = tempInt;

                        allShiftTypes.Add(shiftType);
                    }
                }
            }

            return(allShiftTypes);
        }
コード例 #2
0
        public void DeleteShiftType(ShiftType record)
        {
            using (SqlConnection con = GetConnection())
            {
                con.Open();

                SqlCommand command = new SqlCommand("DeleteShiftType", con);
                command.CommandType = CommandType.StoredProcedure;

                SqlParameter shiftID = GetParameter("@ShiftID", SqlDbType.Int, record.ShiftID);

                command.Parameters.Add(shiftID);

                var results = command.ExecuteNonQuery();
            }
        }
コード例 #3
0
        public void AddOrUpdateShiftType(ShiftType record, string sp)
        {
            using (SqlConnection con = GetConnection())
            {
                con.Open();

                SqlCommand command = new SqlCommand(sp, con);
                command.CommandType = CommandType.StoredProcedure;

                SqlParameter shiftID = GetParameter("@ShiftID", SqlDbType.Int, record.ShiftID);
                SqlParameter name    = GetParameter("@Name", SqlDbType.VarChar, record.Name);

                command.Parameters.Add(shiftID);
                command.Parameters.Add(name);

                var results = command.ExecuteNonQuery();
            }
        }
コード例 #4
0
 public void UpdateShiftType(ShiftType record)
 {
     AddOrUpdateShiftType(record, "UpdateShiftType");
 }
コード例 #5
0
 public void AddShiftType(ShiftType record)
 {
     AddOrUpdateShiftType(record, "InsertShiftTypes");
 }